org.norther.tammi.acorn.net
Class URLInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.norther.tammi.acorn.net.URLInputStream
All Implemented Interfaces:
Closeable

public class URLInputStream
extends InputStream

An input stream reading from a specific URL.

The stream can be closed automatically at EOF with the first stream closing option. However, the mark and reset operations won't work for a stream that is closed after reaching its EOF.

Version:
$Id: URLInputStream.java,v 1.11 2009/09/29 12:34:42 cvsimp Exp $
Author:
Ilkka Priha

Constructor Summary
URLInputStream(URL url, boolean... options)
          Constructs a new URL input stream.
URLInputStream(URL url, String enc, boolean... options)
          Constructs a new URL input stream with an encoding check.
 
Method Summary
 int available()
           
 void close()
           
protected  void finalize()
           
 String getEncoding()
          Gets the Unicode encoding of this stream.
 void mark(int readlimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

URLInputStream

public URLInputStream(URL url,
                      boolean... options)
               throws IOException
Constructs a new URL input stream.

Parameters:
url - the URL of the stream.
options - the closing options.
Throws:
IOException - on I/O errors.

URLInputStream

public URLInputStream(URL url,
                      String enc,
                      boolean... options)
               throws IOException
Constructs a new URL input stream with an encoding check.

Parameters:
url - the URL of the stream.
enc - an optional default encoding.
options - the closing options.
Throws:
IOException - on I/O errors.
Method Detail

available

public int available()
              throws IOException
Overrides:
available in class InputStream
Throws:
IOException

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

mark

public void mark(int readlimit)
Overrides:
mark in class InputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class InputStream

reset

public void reset()
           throws IOException
Overrides:
reset in class InputStream
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Overrides:
skip in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

getEncoding

public String getEncoding()
                   throws IOException
Gets the Unicode encoding of this stream.

Returns:
the Unicode encoding or the default encoding.
Throws:
IOException - on I/O errors.

finalize

protected void finalize()
Overrides:
finalize in class Object


Copyright © 2004 The Norther Organization. All rights reserved.