The ByteArrayOutputStream class writes data into the successive components of a byte array using the methods of java.io.OutputStream :
The two main classes are
- java.io.InputStream and
These are abstract base classes for
many different subclasses
with more-specialized abilities.
are abstract classes, many methods in the class library are only
specified to return an InputStream
not the more-specific subclass
You can read the contents of a web page with this sequence of commands.
String address = "http://java.sun.com/index.html";
URL u = new URL(address);
URLConnection connection = u.openConnection();
InputStream stream = connection.getInputStream();
Scanner in = new Scanner(stream);
Some of these methods may throw exceptions