[英]Reading .txt file in every 4 byte in java (4 byte by 4 byte!)
我尝试使用我在这里找到的以下代码,但我的问题没有解决。
byte[] buffer = new byte[4];
FileInputStream fileInput = new FileInputStream("fileName.txt");
int currentByte = fileInput.read(buffer);
您的问题是您只读取了 4 个字节。 使用while
循环继续读取,直到文件被完全读取。
while ((String line = fileInput.read(buffer)) != null) {
// do something
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.