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

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

public final class StreamUtils
extends Object

Helper class to perform stream operations.

Author:
Kevin Winter

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

Constructor Detail

StreamUtils

public StreamUtils()
Default constructor.

Method Detail

wrapString

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

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

readAll

public String readAll(InputStream inputStream)
               throws IOException
Reads all input into memory 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 void write(String str,
                  OutputStream outputStream)
           throws IOException
Writes the specified string to stream with buffering.

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

copy

public 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.