Refine search
@Override protected void closeIterator() { IO.close(input); input = null; }
private InputStream openChangesSrc(String x) { // May change to cope with remote source return IO.openFile(x) ; }
/** Open a file for output - may include adding gzip processing. */ static public OutputStream openOutputFile(String filename) { try { return openOutputFileEx(filename) ; } catch (IOException ex) { IO.exception(ex) ; return null ; } }
/** Open an input stream to a file. * If the filename is null or "-", return System.in * If the filename ends in .gz, wrap in GZIPInputStream */ static public InputStream openFile(String filename) { try { return openFileEx(filename) ; } catch (IOException ex) { IO.exception(ex); return null ; } }
/** Read a whole stream as UTF-8 * * @param in InputStream to be read * @return String * @throws IOException */ public static String readWholeFileAsUTF8(InputStream in) throws IOException { // Don't buffer - we're going to read in large chunks anyway Reader r = asUTF8(in) ; return readWholeFileAsUTF8(r) ; }
private static long read(String filename) { try { String str = IO.readWholeFileAsUTF8(filename) ; if ( str.endsWith("\n") ) { str = str.substring(0, str.length()-1) ; } str = str.trim() ; return Long.parseLong(str) ; } catch (IOException ex) { Log.error(TransInteger.class, "IOException: " + ex.getMessage(), ex) ; IO.exception(ex) ; } catch (NumberFormatException ex) { Log.error(TransInteger.class, "NumberformatException: " + ex.getMessage()) ; throw new InternalErrorException(ex) ; } // Not reached. return Long.MIN_VALUE ; }
@Override public void close() { try { reader.close() ; } catch (IOException ex) { IO.exception(ex) ; } }
/** Read a whole file as UTF-8 * @param filename * @return String * @throws IOException */ public static String readWholeFileAsUTF8(String filename) throws IOException { InputStream in = new FileInputStream(filename) ; return readWholeFileAsUTF8(in) ; }
@Override public void flush() { IO.flush(out) ; }