/** * Create a header by reading the information from the input stream. * * @param dis * The input stream to read the data from. * @return <CODE>null</CODE> if there was a problem with the header; * otherwise return the header read from the input stream. * @throws TruncatedFileException * if the stream ended prematurely * @throws IOException * if the header could not be read. */ public static Header readHeader(ArrayDataInput dis) throws TruncatedFileException, IOException { Header myHeader = new Header(); try { myHeader.read(dis); } catch (EOFException e) { if (e.getCause() instanceof TruncatedFileException) { throw e; } // An EOF exception is thrown only if the EOF was detected // when reading the first card. In this case we want // to return a null. return null; } return myHeader; }
/** * Create a header by reading the information from the input stream. * * @param dis * The input stream to read the data from. * @return <CODE>null</CODE> if there was a problem with the header; * otherwise return the header read from the input stream. * @throws TruncatedFileException * if the stream ended prematurely * @throws IOException * if the header could not be read. */ public static Header readHeader(ArrayDataInput dis) throws TruncatedFileException, IOException { Header myHeader = new Header(); try { myHeader.read(dis); } catch (EOFException e) { if (e.getCause() instanceof TruncatedFileException) { throw e; } // An EOF exception is thrown only if the EOF was detected // when reading the first card. In this case we want // to return a null. return null; } return myHeader; }
/** * Read to the end of the associated input stream * * @throws FitsException * if the operation failed */ private void readToEnd() throws FitsException { while (this.dataStr != null && !this.atEOF) { try { if (readHDU() == null) { break; } } catch (EOFException e) { if (FitsFactory.getAllowTerminalJunk() && // e.getCause() instanceof TruncatedFileException && // getNumberOfHDUs() > 0) { this.atEOF = true; return; } throw new FitsException("IO error: " + e); } catch (IOException e) { throw new FitsException("IO error: " + e); } } }
/** * Read to the end of the associated input stream * * @throws FitsException * if the operation failed */ private void readToEnd() throws FitsException { while (this.dataStr != null && !this.atEOF) { try { if (readHDU() == null) { break; } } catch (EOFException e) { if (FitsFactory.getAllowTerminalJunk() && // e.getCause() instanceof TruncatedFileException && // getNumberOfHDUs() > 0) { this.atEOF = true; return; } throw new FitsException("IO error: " + e); } catch (IOException e) { throw new FitsException("IO error: " + e); } } }