读取一个文件的数据流。
//创建文件的file对象
File file = new File(path);
//将file转换成InputStream对象
InputStream is = new FileInputStream(path);
//将file数据流写进databaseFilename文件
FileOutputStream fos = new FileOutputStream(databaseFilename);
byte[] buffer = new byte[8192];
int count = 0;
while ((count = is.read(buffer)) > 0) {
fos.write(buffer, 0, count);
}
fos.close();
is.close();
本文介绍如何使用Java进行文件数据流操作,包括创建File对象、转换为InputStream对象,并将数据流写入目标文件。
2万+

被折叠的 条评论
为什么被折叠?



