com.google.api.ads.common.lib.utils
Class Streams

java.lang.Object
  extended by com.google.api.ads.common.lib.utils.Streams

public final class Streams
extends Object

Helper class to perform stream operations.

Author:
Kevin Winter

Method Summary
static void copy(InputStream inputStream, OutputStream outputStream)
          Copies the inputStream into the outputSteam and finally closes the both streams.
static String readAll(InputStream inputStream)
          Reads all input into memory, close the steam, and return as a String.
static InputStream wrapString(String str)
          Wraps the provided string into an InputStream.
static void write(String str, OutputStream outputStream)
          Writes the specified string to stream with buffering and closes the stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

wrapString

public static InputStream wrapString(String str)
Wraps the provided string into an InputStream.

Parameters:
str - String to wrap.
Returns:
InputStream containing the string argument.

readAll

public static String readAll(InputStream inputStream)
                      throws IOException
Reads all input into memory, close the steam, and return as a String.

Parameters:
inputStream - InputStream to read from.
Returns:
String contents of the stream.
Throws:
IOException - if there is an problem reading from the stream.

write

public static void write(String str,
                         OutputStream outputStream)
                  throws IOException
Writes the specified string to stream with buffering and closes the stream.

Parameters:
str - String to write.
outputStream - Stream to write to.
Throws:
IOException - If there is an exception while writing.

copy

public static void copy(InputStream inputStream,
                        OutputStream outputStream)
                 throws IOException
Copies the inputStream into the outputSteam and finally closes the both streams.

Throws:
IOException


Copyright © 2012. All Rights Reserved.