复制/重写文件

package zz.zd.ty;

import java.io.IOException;
import java.io.RandomAccessFile;

public class Main {
public static void main(String[] args) throws IOException {

    RandomAccessFile accessFile = new RandomAccessFile(
            "E:\\Sutdent\\Student_Info.txt", "r");
    RandomAccessFile accessFile2 = new RandomAccessFile(
            "E:\\Sutdent\\Student2_Info.txt", "rw");

    byte[] bytes = new byte[300];

    int i = -1;

    while ((i = accessFile.read(bytes, 0, bytes.length)) != -1) {

        accessFile2.write(bytes, 0, i);

        if (i >= 300) {
            System.out.println("ssss");
            return;
        }
        System.out.println("ssss1");
    }

}

}

你可能感兴趣的:(复制/重写文件)