美文网首页JAVA
复制/重写文件

复制/重写文件

作者: TY_ | 来源:发表于2016-08-26 18:16 被阅读19次

    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");
        }
    
    }
    

    }

    相关文章

      网友评论

        本文标题:复制/重写文件

        本文链接:https://www.haomeiwen.com/subject/aaezsttx.html