/** * Writes the input stream to the output stream. Input is done without a Reader object, meaning * that the input is copied in its raw form. * * @param in * The input stream * @param out * The output stream * @return Number of bytes copied from one stream to the other * @throws IOException */ public static int copy(final InputStream in, final OutputStream out) throws IOException { return copy(in, out, 4096); }
/** * Read all the data from the resource into memory. * * @param reader * The source reader to load the data from * @throws IOException */ public FullyBufferedReader(final Reader reader) throws IOException { this(Streams.readString(reader)); }
/** * @throws IOException * @see org.apache.wicket.resource.IPropertiesLoader#loadJavaProperties(java.io.InputStream) */ @Override public java.util.Properties loadJavaProperties(final InputStream in) throws IOException { java.util.Properties properties = new java.util.Properties(); Streams.loadFromXml(properties, in); return properties; }
try Streams.copyAndClose(item.openStream(), fileItem.getOutputStream());
/** * Writes the input stream to the output stream. Input is done without a Reader object, meaning * that the input is copied in its raw form. * * @param in * The input stream * @param out * The output stream * @return Number of bytes copied from one stream to the other * @throws IOException */ public static int copy(final InputStream in, final OutputStream out) throws IOException { return copy(in, out, 4096); }
/** * Read all the data from the resource into memory. * * @param reader * The source reader to load the data from * @throws IOException */ public FullyBufferedReader(final Reader reader) throws IOException { super(); input = Streams.readString(reader); }
/** * @throws IOException * @see org.apache.wicket.resource.IPropertiesLoader#loadJavaProperties(java.io.InputStream) */ @Override public java.util.Properties loadJavaProperties(final InputStream in) throws IOException { java.util.Properties properties = new java.util.Properties(); Streams.loadFromXml(properties, in); return properties; }
/** * Writes the given input stream to the given file * * @param file * The file to write to * @param input * The input * @return Number of bytes written * @throws IOException */ public static final int writeTo(final java.io.File file, final InputStream input) throws IOException { final FileOutputStream out = new FileOutputStream(file); try { return Streams.copy(input, out); } finally { out.close(); } }
/** * Read all the data from the resource into memory. * * @param reader * The source reader to load the data from * @throws IOException */ public FullyBufferedReader(final Reader reader) throws IOException { super(); input = Streams.readString(reader); }
/** * * @param in * @return java.util.Properties * @throws IOException */ @Override protected java.util.Properties loadProperties(BufferedInputStream in) throws IOException { java.util.Properties properties = new java.util.Properties(); Streams.loadFromXml(properties, in); return properties; } }
/** * Writes the node data to the specified output stream. * * @param stream * @throws IOException */ public void writeData(OutputStream stream) throws IOException { Streams.copy(getDataAsStream(), stream); }
/** * Reads a stream as a string. * * @param in * The input stream * @return The string * @throws IOException */ public static String readString(final InputStream in) throws IOException { return readString(new BufferedReader(new InputStreamReader(in))); }
if (loadAsXml) Streams.loadFromXml(properties, in);
/** * Writes the given input stream to the given file * * @param file * The file to write to * @param input * The input * @param bufSize * The memory buffer size. 4096 is a good value. * @return Number of bytes written * @throws IOException */ public static int writeTo(final java.io.File file, final InputStream input, final int bufSize) throws IOException { final FileOutputStream out = new FileOutputStream(file); try { return Streams.copy(input, out, bufSize); } finally { out.close(); } }
/** * Reads a stream as a string. * * @param in * The input stream * @return The string * @throws IOException */ public static String readString(final InputStream in) throws IOException { return readString(new BufferedReader(new InputStreamReader(in))); }
/** * Writes the given input stream to the given file * * @param file * The file to write to * @param input * The input * @param bufSize * The memory buffer size. 4096 is a good value. * @return Number of bytes written * @throws IOException */ public static final int writeTo(final java.io.File file, final InputStream input, final int bufSize) throws IOException { final FileOutputStream out = new FileOutputStream(file); try { return Streams.copy(input, out, bufSize); } finally { out.close(); } }
/** * Reads a stream as a string. * * @param in * The input stream * @return The string * @throws IOException */ public static String readString(final InputStream in) throws IOException { return readString(new BufferedReader(new InputStreamReader(in))); }
/** * Copies a resource from classpath to a {@link java.io.File} * * @param source classpath to resource * @param destination destination file */ public static void copyClassResourceToFile(String source, java.io.File destination) { final InputStream in = JcrUtils.class.getResourceAsStream(source); if (in == null) { throw new RuntimeException("Class resource: " + source + " does not exist"); } try { final FileOutputStream fos = new FileOutputStream(destination); Streams.copy(in, fos); fos.close(); in.close(); } catch (IOException e) { throw new RuntimeException("Could not copy class resource: " + source + " to destination: " + destination.getAbsolutePath()); } }
/** * @return String read from this file * @throws IOException */ public final String readString() throws IOException { final InputStream in = new FileInputStream(this); try { return Streams.readString(in); } finally { in.close(); } }
/** * Copies a resource from classpath to a {@link java.io.File} * * @param source classpath to resource * @param destination destination file */ public static void copyClassResourceToFile(String source, java.io.File destination) { final InputStream in = JcrUtils.class.getResourceAsStream(source); if (in == null) { throw new RuntimeException("Class resource: " + source + " does not exist"); } try { final FileOutputStream fos = new FileOutputStream(destination); Streams.copy(in, fos); fos.close(); in.close(); } catch (IOException e) { throw new RuntimeException("Could not copy class resource: " + source + " to destination: " + destination.getAbsolutePath()); } }