FileOutputStream\write

String oldfilepath = "/sdcard/2.txt"
File file = new File(oldfilepath);
int file1size = (int)file.length();
//读取文件数据
byte[] bt = new byte[file1size];
FileInputStream filein = new FileInputStream(file);
filein.read()
//新建的文件路径
String filepath = "/sdcard/1.txt"
//输出流到,流到"/sdcard/1.txt",即创建文件
FileOutputStream fileout = new FileOutputStream(filepath);
int count = 0;
//输入流读取数据不是一次性读完,分段进行,返回读取的数据长度
while((count=filein.read(bt)) != -1){
      fileout.write(bt, 0, count);
}

暂时不知 fileout.write方法中的偏移为什么一直指向0?

你可能感兴趣的:(FileOutputStream\write)