簡體   English   中英

以相反的順序將文件轉換為字節數組

[英]Convert file to byte array in reverse order

byte[] bFile = new byte[(int) file.length()];

FileInputStream fileInputStream = new FileInputStream(file);
fileInputStream.read(bFile);
fileInputStream.close();

這個代碼讓我把文件轉換成字節數組,我正在尋找從頭到尾讀取文件(以相反的順序)

編輯:我不想讀整個文件。 最后的一部分(例如大約1000字節)

File file = new File(/*file path*/);
byte[] bFile = new byte[1000];

RandomAccessFile fileInputStream = new RandomAccessFile(file, "r");
fileInputStream.seek(fileInputStream.length() - bFile[0].length);
fileInputStream.read(bFile, 0, bFile.length);
fileInputStream.close();

我只想弄清楚,讀取文件的最后1000個字節

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM