Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
The following two classes have been deprecated injava.io
.LineNumberInputStream
was deprecated because it incorrectly assumes that bytes adequately represent characters.StringBufferInputStream
was deprecated because it does not properly convert characters into bytes. As of JDK 1.1, the preferred way to operate on character streams is via the new set of character-stream classes which provides character-based alternatives to bothLineNumberInputStream
andStringBufferInputStream
.
Deprecated Class Alternative LineNumberInputStream
LineNumberReader
StringBufferInputStream
StringReader
java.io.ByteArrayOutputStream
ClassThe following method injava.io.ByteArrayOutputStream
was deprecated because it does not properly convert bytes into characters. As of JDK 1.1, the preferred way to do this is via one of the other twotoString
methods, which allow the caller to specify the character encoding to use to convert bytes to characters or uses the platform's default character encoding.
Deprecated Method Alternative String toString(int hibyte)
String toString()
orString toString(String enc)
java.io.DataInputStream
ClassThe following method injava.io.DataInputStream
has been deprecated because it does not properly convert bytes to characters.
Deprecated Method Alternative String readLine()
String BufferedReader.readLine()
The alternative shown here will not work for all programs. For examples and discussion about other choices, see How to Convert Code that Uses I/O.
java.io.PrintStream
ClassThejava.io.PrintStream
class has been superceded by the character-basedjava.io.PrintWriter
class. To discourage its use all the constructors forjava.io.PrintStream
have been deprecated.
Deprecated Method Alternative PrintStream(OutputStream)
PrintWriter(OutputStream)
PrintStream(OutputStream, boolean)
PrintWriter(OutputStream, boolean)
Related Notes: ThePrintStream
class has been modified to use the platform's default character encoding and the platform's default line terminator. Thus eachPrintStream
incorporates anOutputStreamWriter
, and it passes all characters through this writer to produce bytes for output. Theprintln
methods use the platform's default line terminator, which is defined by the system propertyline.separator
and is not necessarily a single newline character ('\n'
). Bytes and byte arrays written via the existingwrite
methods are not passed through the writer.The primary motivation for changing the
PrintStream
class is that it will makeSystem.out
andSystem.err
more useful to people writing Java programs on platforms where the local encoding is something other than ASCII.PrintStream
is, in other words, provided primarily for use in debugging and for compatibility with existing code. Therefore its two constructors have been deprecated.Deprecating the constructors rather than the entire class allows existing uses of
System.out
andSystem.err
to be compiled without generating deprecation warnings. Thus programmers just learning Java, or programmers insertingSystem.err.println
calls for debugging purposes, will not be bothered by such warnings. Programmers writing code that explicitly constructs aPrintStream
, on the other hand, will see a deprecation warning when that code is compiled. Code that produces textual output should use the newPrintWriter
class, which allows the character encoding to be specified or the default encoding to be accepted. For convenience, thePrintWriter
class provides constructors that take anOutputStream
object and create an intermediateOutputStreamWriter
object that uses the default encoding.
java.io.StreamTokenizer
ClassThe constructor forjava.io.StreamTokenizer
that operates on anInputStream
has been deprecated in favor of the constructor that operates on aReader
. You can still tokenize anInputStream
by converting it to a Reader:Reader r = new BufferedReader(new InputStreamReader(is)); StreamTokenizer st = new StreamTokenizer(r);
Deprecated Method Alternative StreamTokenizer(InputStream)
StreamTokenizer(Reader)
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
Copyright 1995-2005 Sun Microsystems, Inc. All rights reserved.