请将这段C语言转为java语言while ((data_size = fread(&buff, 1, 1, file)) == 1)
时间: 2023-10-08 22:10:34 浏览: 68
void readFile(String filePath) {
int dataSize;
byte[] data = new byte[1024];
FileInputStream fileInputStream = null;
try {
fileInputStream = new FileInputStream(filePath);
while ((dataSize = fileInputStream.read(data)) != -1) {
// do something with the data
}
fileInputStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
阅读全文