无效的流标头

时间:2016-04-05 01:26:46

标签: java file-io binaryfiles

我正在尝试读取我老师提供的二进制文件,并且我不断收到java.io.StreamCorruptedException:无效的流标题。我该如何解决?

public class BinaryPart {
  public static void main(String[] args) throws IOException{
  ObjectInputStream inputStream = null;
  String fileName = "HW5Input.bin";
    try{
        inputStream = new ObjectInputStream(new FileInputStream(fileName));
    }catch(IOException e){
        System.out.println("There was a problem opening the file: " + e);
        System.exit(0);
    }try{
        byte var1 = inputStream.readByte();
        inputStream.close();
    }catch(Exception e){
        System.out.println("There was an issue reading from the file: " + e);
        System.exit(0);
    }
  }}

0 个答案:

没有答案