JAVA -- 使用BASE64Decoder
来源:互联网 发布:淘宝店铺消保怎么交 编辑:程序博客网 时间:2024/06/01 07:57
package cn.com.toyota.ucar.webservices.vehiclerepertory;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.OutputStreamWriter;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
/**
* 使用sun.misc.BASE64Decoder和sun.misc.BASE64Encoder
* 完成文件转化二进制之间互相转化
* @author Ginger_Z
*
*/
public class BASE64test {
/**
*
* @param path 目标文件
* @param path2 生成文件
* @return
* @throws Exception
*/
public static void encodeBase64File(String path,String path2) throws Exception {
File file = new File(path);//创建目标文件对象
FileInputStream inputFile = new FileInputStream(file);//输入流
FileOutputStream out=new FileOutputStream(path2);//输出流
OutputStreamWriter osw=new OutputStreamWriter(out);//文字写入流
//文件读取时未使用缓冲,一次性读取
byte[] buffer = new byte[(int) file.length()];
inputFile.read(buffer);
inputFile.close();
//new BASE64Encoder().encode(buffer返回String类型的字符串
//再使用文字输出流将其写出
osw.write((new BASE64Encoder().encode(buffer)));
osw.close();
out.close();
}
public static void main(String[] args) {
String path="C:\\Users\\Public\\Pictures\\Sample Pictures\\EAG42EqA_2560x1600.jpg";
String path1="C:\\Users\\Public\\Pictures\\Sample Pictures\\EAG42EqA_2560x16002.txt";
try {
encodeBase64File(path,path1);
File file=new File(path1);
FileInputStream fis=new FileInputStream(file);
FileOutputStream fos=new FileOutputStream("C:\\Users\\Public\\Pictures\\Sample Pictures\\EAG42EqA_2560x16003.jpg");
BASE64Decoder bd=new BASE64Decoder();
byte[] b=bd.decodeBuffer(fis);
fos.write(b);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
- JAVA -- 使用BASE64Decoder
- BASE64Decoder java
- 使用crypto++ base64Decoder
- BASE64Decoder
- 使用sun.misc.BASE64Decoder出错解决方案
- 使用sun.misc.BASE64Decoder出错解决方案
- BASE64Encoder及BASE64Decoder问题解答和使用策略
- 在Eclipse使用BASE64Decoder的心得
- Java中用到BASE64Decoder相关错误
- Java实现BASE64Decoder编写加密和解码
- eclipse下使用使用sun.misc.BASE64Decoder出错解决方案
- Java加密算法---sun.misc.BASE64Decoder与sun.misc.BASE64Encoder
- BASE64Decoder小解
- BASE64Decoder小解
- BASE64Decoder小解
- BASE64Decoder小解
- BASE64Decoder小解
- BASE64Decoder小解
- ubuntu 卸载 gitlab
- java Web项目Service层通用接口和entityVo对象与entity对象转化问题的解决方案
- Nginx的配置文件
- Spring Junit 单元测试实例
- Gradle Plugin Samples 之 Gradle Eclipse Compatible (三)
- JAVA -- 使用BASE64Decoder
- Ajax 请求标准规格
- Pure Android
- Android集成一个新产品时,lunch的product name和device name注意事项
- linux系统iNode耗尽
- 知识点
- EqualsBuilder类的使用
- Android轮播图-----viewPager
- Gradle Plugin Samples 之Gradle Library Projects(四)