/** * updates listener when required */ public int read() throws IOException { //by doing this before we're out by one byte... this might be bad... if ((bytesRead % interval) == 0) { listener.setStreamProgress(bytesRead); } return super.read(); }
/** * tells listener the stream is complete */ public void close() throws IOException { super.close(); listener.setStreamClosed(); }
/** * tells listener the stream is complete */ public void close() throws IOException { super.close(); listener.setStreamClosed(); }
/** * Convenience routine to wrap given readers/writers in Buffereds */ public static void bufferedPipe(Reader in, Writer out) throws IOException { out = new BufferedWriter(out); pipe(new BufferedReader(in), out); out.flush(); }
/** read stream contents into a string */ public static String getStreamContents(InputStream is) throws IOException { assertNotNull(is); StringWriter sw = new StringWriter(); Piper.bufferedPipe(new InputStreamReader(is), sw); return sw.toString(); } /** handler passed to schema-validation parses - logs all errors, throws assertion failed if errors seen by end */
/** * increments bytesWritten and writes byte to wrapped out */ public void write(int b) throws IOException { super.write(b); if ((bytesWritten % interval) == 0) { listener.setStreamProgress(bytesWritten); } }
/** Normal writer resolver; returns a NoCloseWriter wrapper if doClose is false */ public Writer openWriter() { if (doClose) { return out; } else { return new NoCloseWriter(out); } }
/** All targets must be able to resolve to a stream. The user is required * for permissioning. */ public OutputStream openOutputStream() { return new NullOutputStream(); }
/** All targets must be able to resolve to a stream. The user is required * for permissioning. */ public OutputStream openOutputStream() { return new WriterStream(openWriter()); }
public OutputStream openOutputStream() throws IOException { OutputStream[] outs = new OutputStream[targets.length]; for (int i = 0; i < targets.length; i++) { outs[i] = targets[i].openOutputStream(); } return new MultiCastOutputStream(outs); }
/** * Delete a directory even if it still contains other files. This is a utility method to augment the behaviour of the standard {@link File#delete()} method which will not delete the directory if files still exist. * @param dir the directory to be deleted. * @return */ public static boolean forceDeleteDirectory(File dir) { boolean result = false; if (dir != null & dir.isDirectory()) { File[] files = dir.listFiles(); for (int i = 0; i < files.length; i++) { File file = files[i]; if (file.isDirectory()) { result = forceDeleteDirectory(file); } else { result = file.delete(); } if (!result) //if the delete failed for some reason early exit { return result; } } result = dir.delete(); } return result; }
/** Convenience routine to wrap given streams in Buffered*putStreams and * pipe */ public static void bufferedPipe(InputStream in, OutputStream out) throws IOException { out = new BufferedOutputStream(out); pipe(new BufferedInputStream(in), out); out.flush(); }
/** Writes results to the given TableWriter */ public void writeTable(TableWriter tableWriter, QuerierStatus statusToUpdate) throws IOException { if (tableWriter instanceof VoTableWriter) { Piper.bufferedPipe(new InputStreamReader(in), ((VoTableWriter) tableWriter).getOut()); } else { throw new UnsupportedOperationException("Can only write to votables"); } }
/** * updates listener when required */ public int read() throws IOException { //by doing this before we're out by one byte... this might be bad... if ((bytesRead % interval) == 0) { listener.setStreamProgress(bytesRead); } return super.read(); }
/** * tells listener the stream is complete */ public void close() throws IOException { super.close(); listener.setStreamClosed(); }
/** * tells listener the stream is complete */ public void close() throws IOException { super.close(); listener.setStreamClosed(); }
/** * increments bytesWritten and writes byte to wrapped out */ public void write(int b) throws IOException { super.write(b); if ((bytesWritten % interval) == 0) { listener.setStreamProgress(bytesWritten); } }
/** All targets must be able to resolve to a writer. The user is required * for permissions */ public Writer openWriter() throws IOException { return new NoCloseWriter(response.getWriter()); }
/** * Convenience routine to wrap given readers/writers in Buffereds */ public static void bufferedPipe(Reader in, Writer out) throws IOException { out = new BufferedWriter(out); pipe(new BufferedReader(in), out); out.flush(); }
/** Convenience routine to wrap given streams in Buffered*putStreams and * pipe */ public static void bufferedPipe(InputStream in, OutputStream out) throws IOException { out = new BufferedOutputStream(out); pipe(new BufferedInputStream(in), out); out.flush(); }