使用Base64对文件流进行编码

  1. public String encode(InputStream in)throws IOException{
  2. sun.misc.BASE64Encoder encoder = new sun.misc.BASE64Encoder();
  3. byte[] data = new byte[in.available()];
  4. in.read(data);
  5. return encoder.encode(data);
  6. }
  7. public byte[] decode(String base64Str)throws IOException{
  8. sun.misc.BASE64Decoder decoder = new sun.misc.BASE64Decoder();
  9. return decoder.decodeBuffer(base64Str);
  10. }

评论

此博客中的热门博文

【机场测试】海豚湾

【机场测试】喵帕斯

SQL注入步骤