1 Star 0 Fork 1.4K

java-utils/DocSys

forked from Rainy/DocSys 
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
Base64File.java 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
zju_rain 提交于 2017-09-28 11:12 +08:00 . DocSys First Version
/**
*
*/
package util;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import com.ibm.misc.BASE64Decoder;
/**
* @author Administrator
*
*/
public class Base64File {
/**
* @param args
*/
public static void main(String[] args) {
decode("MTIzYWJj","D:\\","qq.txt");
}
/**
* 直接将解密内容写入文件
*
* @param bytes
* @param path
* @param file
*/
public static void decode(String bytes, String path, String file) {
byte[] content = decode(bytes);
FileOutputStream fos = null;
try {
File dir = new File(path);
if (!dir.exists()) {
DebugHelper.print("文件夹" + path + "不存在");
dir.mkdir();
}
System.out.println( "s " + dir.setWritable(true));
System.out.println( "w " + dir.canWrite());
System.out.println( "r " + dir.canRead());
DebugHelper.print( "重新检测" + dir.exists() );
fos = new FileOutputStream(path + file);
fos.write(content);
} catch (Exception e) {
DebugHelper.print(e.toString());
} finally {
try {
fos.close();
} catch (IOException e) {
// 不做处理
}
}
}
/**
* 将字符串解密
*
* @param bytes
* @return
*/
public static byte[] decode(String data) {
if (null == data) {
return null;
}
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] ret = decoder.decodeBuffer(data);
return ret;
} catch (Exception e) {
DebugHelper.print(e.toString());
return null;
}
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/java-utils/DocSys.git
git@gitee.com:java-utils/DocSys.git
java-utils
DocSys
DocSys
master

搜索帮助