de.fhg.igd.io
Class URLOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by de.fhg.igd.io.URLOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class URLOutputStream
extends OutputStream

This is an OutputStream wrapper that tries to open a stream to the specified URL.

Besides the definitions of RFC 1738, "socket" will be accepted as an additional protocol identifier for the URL of a TCP socket (provided by ServerSocket or the like), e.g. socket://192.168.0.1:30000

This class fully supports output to URLs pointing to a file. All other protocols depend on the output stream handler provided by URLConnection and will make the constructor throw an exception in case output is not supported.

Version:
$Id: URLOutputStream.java 1913 2007-08-08 02:41:53Z jpeters $
Author:
Matthias Pressfreund

Field Summary
protected  OutputStream os_
          The wrapped output stream
 
Constructor Summary
URLOutputStream(URL url)
          Creates a URLOutputStream which tries to connect to the given URL.
 
Method Summary
 void close()
          Calls the corresponding method on the wrapped OutputStream.
 void flush()
          Calls the corresponding method on the wrapped OutputStream.
 void write(byte[] b)
          Calls the corresponding method on the wrapped OutputStream.
 void write(byte[] b, int off, int len)
          Calls the corresponding method on the wrapped OutputStream.
 void write(int b)
          Calls the corresponding method on the wrapped OutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

os_

protected OutputStream os_
The wrapped output stream

Constructor Detail

URLOutputStream

public URLOutputStream(URL url)
                throws IOException
Creates a URLOutputStream which tries to connect to the given URL.

Parameters:
url - The destination URL
Throws:
IOException - in case there is no output stream handler provided for the given URL
Method Detail

write

public void write(int b)
           throws IOException
Calls the corresponding method on the wrapped OutputStream.

Specified by:
write in class OutputStream
Throws:
IOException
See Also:
OutputStream.write(int)

write

public void write(byte[] b)
           throws IOException
Calls the corresponding method on the wrapped OutputStream.

Overrides:
write in class OutputStream
Throws:
IOException
See Also:
OutputStream.write(byte[])

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Calls the corresponding method on the wrapped OutputStream.

Overrides:
write in class OutputStream
Throws:
IOException
See Also:
OutputStream.write(byte[],int,int)

flush

public void flush()
           throws IOException
Calls the corresponding method on the wrapped OutputStream.

Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException
See Also:
OutputStream.flush()

close

public void close()
           throws IOException
Calls the corresponding method on the wrapped OutputStream.

Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException
See Also:
OutputStream.close()


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.