国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
java 文件使用BASE64編碼解碼
有的時候我們需要將文件通過base64進行編碼解碼來傳遞。
編碼過程:
 
public static void main(String[] args) {
 
      InputStream inputStream =null;
      File file = new File("D:\\index.htm");
      try {
            inputStream = new FileInputStream(file);
            byte [] fileByte = new byte[inputStream.available()];
            String fileString = new BASE64Encoder().encode(fileByte);
      } catch(Exception e) {
            e.printStackTrace();
      } finally {
            if(inputStream != null){
                  try {
                        inputStream.close();
                  } catch (IOException e) {
                        e.printStackTrace();
                  }
            }
      }
}
 
相反的解碼過程為:
 
public static void main(String[] args) {
 
      byte [] fileByte = new BASE64Decoder().decodeBuffer(fileStream);
      BufferedOutputStream stream = null;
      File file = null;
      try {
            file = new File("D:\\decode.htm");
            FileOutputStream fstream = new FileOutputStream(file);
            stream = new BufferedOutputStream(fstream);
            stream.write(fileByte);
      } catch(Exception e) {
            e.printStackTrace();
      } finally {
            if(stream!= null){
                  try {
                        stream.close();
                  } catch (IOException e) {
                        e.printStackTrace();
                  }
            }
      }
}
本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
java base64 轉(zhuǎn)碼和解碼
基于SMB/JCIFS協(xié)議的共享文件上傳和下載
HttpURLConnection(訪問網(wǎng)絡)
Java對網(wǎng)絡圖片/本地圖片轉(zhuǎn)換成Base64編碼和解碼
java IO操作 按照規(guī)律合并兩個txt文件
InputStream中read()與read(byte[] b)
更多類似文章 >>
生活服務
分享 收藏 導長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服