有什麼像掃描儀的二進制數據?我希望例如使用分隔符,如「\ r \ n」,並在每次調用某個方法時都獲取byte []。你能給我提供可以創造奇蹟的課嗎?類似掃描儀的二進制數據
2
A
回答
0
雅加達公共有一個圖書館,你可以使用。只需從jakarta下載.jar並下載它們的.jar,然後通過添加外部jar將其添加到您的構建路徑中。 IOUtils.toByteArray(InputStream input)
0
可以使用java.io.InputStream類:
InputStream is = new FileInputStream("your_file");
byte[] b = new byte[is.available()]; //reads how much bytes are readable from file
is.read(b);//reads the file and save all read bytes into b
希望這有助於
1
考慮使用DataInputStream
和DataOutputStream
:
File file = new File("binaryFile.dat");
FileOutputStream fos = new FileOutputStream(file);
BufferedOutputStream bos = new BufferedOutputStream(fos);
DataOutputStream dos = new DataOutputStream(bos);
byte[] array1 = ...
byte[] array2 = ...
byte[] array3 = ...
dos.writeInt(array1.length);
for(byte b : array1) dos.wrtieByte(b);
dos.writeInt(array2.length);
for(byte b : array2) dos.wrtieByte(b);
dos.writeInt(array3.length);
for(byte b : array3) dos.wrtieByte(b);
和閱讀喜歡:
File file = new File("binaryFile.dat");
FileInputStream fis = new FileInputStream(file);
BufferedInputStream bis = new BufferedInputStream(fis);
DataInputStream dis = new DataInputStream(bis);
byte[] array1 = new byte[dis.readInt()];
for(int i = 0; i < array1.length; i++) array1[i] = dis.readByte();
byte[] array2 = new byte[dis.readInt()];
for(int i = 0; i < array2.length; i++) array2[i] = dis.readByte();
byte[] array3 = new byte[dis.readInt()];
for(int i = 0; i < array3.length; i++) array3[i] = dis.readByte();
相關問題
- 1. 掃描,掃描儀類
- 2. 掃描儀類 - hasNextDouble()
- 3. PHP類掃描儀
- 4. 掃描儀類Java
- 5. 如何處理從條形碼掃描儀返回的二進制數據?
- 6. 掃描儀內的掃描儀錯誤
- 7. 進度條類似條碼掃描儀照片拍攝圖像
- 8. 爲什麼關閉掃描儀似乎破壞了新的掃描儀?
- 9. 控制檯掃描儀?
- 10. 掃描antlr3中的二進制文件
- 11. 掃描儀類方法
- 12. 使用掃描儀類
- 13. 抽象類與掃描儀
- 14. java - 掃描儀類NoSuchElementFoundException
- 15. 掃描儀類幫助
- 16. 掃描儀+ TesterClass?
- 17. JFileChooser掃描儀?
- 18. 掃描儀NoSuchElementException
- 19. 與掃描儀
- 20. 與掃描儀
- 21. 掃描儀,useDelimiter
- 22. 由掃描儀
- 23. ArrayList的掃描儀
- 24. 掃描儀不掃描我的輸入
- 25. 掃描20次的Wifi掃描儀
- 26. 使用PCL二維激光掃描儀
- 27. 條碼掃描儀數據提取
- 28. 從掃描儀只讀數
- 29. Java - 使用掃描儀以十六進制數字讀取
- 30. 使用掃描儀掃描txt文件
但我想要例如整行字節。 – oneat 2013-03-05 18:33:22