java FileInputStream读取文件

java FileInputStream读取文件

 

public static void readFileData(String filePath) throws IOException {
    File classFile = new File(filePath);
    FileInputStream fis = new FileInputStream(classFile);
    byte[] bytes1 = new byte[1024];
    int len=0;
    while((len=fis.read(bytes1))!=-1) {
        String s = new String(bytes1,0,len);
        System.out.println(s);
    }
    
    fis.close();
}

 

 

 

##############################

posted @ 2022-12-04 21:57  西北逍遥  阅读(191)  评论(0编辑  收藏  举报