Reading the first 10 bytes of a file in Java

后端 未结 2 1213
挽巷
挽巷 2021-01-22 09:32
    for (String name : filenames) {   
FileInputStream in = new FileInputStream(input.readUTF());   
    int byteCounter = 0;   
    int rowCounter = 0;   
    long buff         


        
2条回答
  •  佛祖请我去吃肉
    2021-01-22 10:14

    the problem is here

    System.out.print(Integer.toHexString(read) + "\t");
    

    read contains the number of bytes effectively read from stream. Teh bytes are in array b.

    By the way: your array has a size of 8. you should increas it to 10 if you want to read 10 bytes!

提交回复
热议问题