国产片侵犯亲女视频播放_亚洲精品二区_在线免费国产视频_欧美精品一区二区三区在线_少妇久久久_在线观看av不卡

服務器之家:專注于服務器技術及軟件下載分享
分類導航

PHP教程|ASP.NET教程|Java教程|ASP教程|編程技術|正則表達式|C/C++|IOS|C#|Swift|Android|VB|R語言|JavaScript|易語言|vb.net|

服務器之家 - 編程語言 - Java教程 - java 文件和byte互轉的實例

java 文件和byte互轉的實例

2021-02-05 12:23BeforeYou Java教程

下面小編就為大家分享一篇java 文件和byte互轉的實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

實例如下所示:

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/**
  * 獲得指定文件的byte數組
  */
 private byte[] getBytes(String filePath){
  byte[] buffer = null;
  try {
   File file = new File(filePath);
   FileInputStream fis = new FileInputStream(file);
   ByteArrayOutputStream bos = new ByteArrayOutputStream(1000);
   byte[] b = new byte[1000];
   int n;
   while ((n = fis.read(b)) != -1) {
    bos.write(b, 0, n);
   }
   fis.close();
   bos.close();
   buffer = bos.toByteArray();
  } catch (FileNotFoundException e) {
   e.printStackTrace();
  } catch (IOException e) {
   e.printStackTrace();
  }
  return buffer;
 }
 
 /**
  * 根據byte數組,生成文件
  */
 public static void getFile(byte[] bfile, String filePath,String fileName) {
  BufferedOutputStream bos = null;
  FileOutputStream fos = null;
  File file = null;
  try {
   File dir = new File(filePath);
   if(!dir.exists()&&dir.isDirectory()){//判斷文件目錄是否存在
    dir.mkdirs();
   }
   file = new File(filePath+"\\"+fileName);
   fos = new FileOutputStream(file);
   bos = new BufferedOutputStream(fos);
   bos.write(bfile);
  } catch (Exception e) {
   e.printStackTrace();
  } finally {
   if (bos != null) {
    try {
     bos.close();
    } catch (IOException e1) {
     e1.printStackTrace();
    }
   }
   if (fos != null) {
    try {
     fos.close();
    } catch (IOException e1) {
     e1.printStackTrace();
    }
   }
  }
 }

以上這篇java 文件和byte互轉的實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持服務器之家。

原文鏈接:http://www.cnblogs.com/yanjie-java/p/7838876.html

延伸 · 閱讀

精彩推薦
Weibo Article 1 Weibo Article 2 Weibo Article 3 Weibo Article 4 Weibo Article 5 Weibo Article 6 Weibo Article 7 Weibo Article 8 Weibo Article 9 Weibo Article 10 Weibo Article 11 Weibo Article 12 Weibo Article 13 Weibo Article 14 Weibo Article 15 Weibo Article 16 Weibo Article 17 Weibo Article 18 Weibo Article 19 Weibo Article 20 Weibo Article 21 Weibo Article 22 Weibo Article 23 Weibo Article 24 Weibo Article 25 Weibo Article 26 Weibo Article 27 Weibo Article 28 Weibo Article 29 Weibo Article 30 Weibo Article 31 Weibo Article 32 Weibo Article 33 Weibo Article 34 Weibo Article 35 Weibo Article 36 Weibo Article 37 Weibo Article 38 Weibo Article 39 Weibo Article 40
主站蜘蛛池模板: 久久66| 中文字幕1区2区3区 亚洲欧美日韩精品久久亚洲区 | 成人午夜在线 | 欧美激情一区二区 | 成人国产电影 | 日韩在线观看第一页 | 亚洲精品一区二三区不卡 | 成人久久久精品乱码一区二区三区 | 午夜视频在线播放 | 91社区在线高清 | 欧美日本一区 | 免费特级黄毛片 | 亚洲欧美日韩成人 | 国产日韩一级片 | 一区二区三区日韩 | 亚洲欧美一区二区三区情侣bbw | av免费观看网站 | 国产美女一区二区三区 | 亚洲日韩中文字幕一区 | 成人日韩在线 | 在线小视频国产 | 免费视频一区二区 | 国产精品99久久久久久动医院 | 亚洲一区 日韩精品 中文字幕 | 噜噜噜在线 | 亚洲伊人久久综合 | 欧美日韩不卡在线 | 国产精品毛片一区二区三区 | 国产欧美日韩精品一区 | 97久久精品人人澡人人爽 | 久色视频在线观看 | 日韩综合在线 | 九九热精品在线 | 日韩欧美国产精品综合嫩v 日韩a∨精品日韩在线观看 | 国产大片一区 | 欧美精品日韩精品 | 日韩精品一区在线视频 | 亚洲字幕网 | av网址在线播放 | 91在线精品视频观看 | 亚洲 欧美 日韩在线 |