}
}
fr.close();
fw.close();//将缓冲区里面的内容刷到文件里,释放关联的文件资源
} 作者: Benwolf0818 时间: 2013-3-2 19:10
java API 里的解释为
public void close()
throws IOException
从类 Writer 复制的描述
关闭此流,但要先刷新它。在关闭该流之后,再调用 write() 或 flush() 将导致抛出 IOException。关闭以前关闭的流无效。作者: 明锦添 时间: 2013-3-4 22:29
public class Test {
public static void main(String[] args) throws IOException {
String sourcePath = "D:/exam.doc";
String destPath = "E:/exam.doc";
int length = -1;
byte[] arrs = new byte[1024];
File sourFile = new File(sourcePath);
FileInputStream inputStream = new FileInputStream(sourFile);
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
File destFile = new File(destPath);
FileOutputStream outputStream = new FileOutputStream(destFile);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);
while ((length = bufferedInputStream.read(arrs)) != -1) {
bufferedOutputStream.write(arrs, 0, length);
}
bufferedOutputStream.close();
outputStream.close();
bufferedInputStream.close();
inputStream.close();
System.out.println("文件复制成功!");
}
}作者: 明锦添 时间: 2013-3-4 22:30
public class Test {
public static void main(String[] args) throws IOException {
String sourcePath = "D:/exam.doc";
String destPath = "E:/exam.doc";
int length = -1;
byte[] arrs = new byte[1024];
File sourFile = new File(sourcePath);
FileInputStream inputStream = new FileInputStream(sourFile);
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
File destFile = new File(destPath);
FileOutputStream outputStream = new FileOutputStream(destFile);
BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(outputStream);