本帖最后由 徐升2013 于 2013-4-6 18:47 编辑
- public class Test {
- public static void main(String[] args) {
- BufferedInputStream bfin = null;
- BufferedOutputStream bfot = null;
- try {
- bfin = new BufferedInputStream(
- new FileInputStream("d:" + File.separator + "1.mp3"));
- bfot = new BufferedOutputStream(
- new FileOutputStream("d:" + File.separator + "2.mp3"));
- byte[] buf = new byte[1024 * 1024 * 2];
- int len = 0;
- while ((len = bfin.read(buf)) != -1)
- {
- bfot.write(buf, 0, len);System.out.println("拷贝完成");
- }
-
- }
- catch (Exception e) {
- System.out.println("拷贝文件失败" + e.toString());
- }
-
- }
- }
复制代码 代码如上。没执行刷新操作,没执行关闭流的操作。。。拷贝也成功了。真心费解了。。
|