内容转换成base64格式 String ret=new String();
byte[] bytes=new byte[1024];
String aa="aaaa";
bytes=aa.getBytes();
ret=new sun.misc.BASE64Encoder().encode(bytes); //具体的编码方法
bytes = new sun.misc.BASE64Decoder().decodeBuffer(ret);
aa=new String(bytes);
out.println(aa);怎样把文件转换成byte[] private byte[] getContent(String fullfilename) throws IOException {
FileInputStream f = new FileInputStream(fullfilename);
byte[] b = new byte[ (int)new File(fullfilename).length()];
f.read(b);
f.close();
return b;
}
byte[] bytes=new byte[1024];
String aa="aaaa";
bytes=aa.getBytes();
ret=new sun.misc.BASE64Encoder().encode(bytes); //具体的编码方法
bytes = new sun.misc.BASE64Decoder().decodeBuffer(ret);
aa=new String(bytes);
out.println(aa);怎样把文件转换成byte[] private byte[] getContent(String fullfilename) throws IOException {
FileInputStream f = new FileInputStream(fullfilename);
byte[] b = new byte[ (int)new File(fullfilename).length()];
f.read(b);
f.close();
return b;
}
想当年自己用c写的base64转换,也比较简单的