|
|
Start of Tutorial > Start of Trail > Start of Lesson |
Search
Feedback Form |
The following two classes have been deprecated injava.io.LineNumberInputStreamwas deprecated because it incorrectly assumes that bytes adequately represent characters.StringBufferInputStreamwas 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 bothLineNumberInputStreamandStringBufferInputStream.
Deprecated Class Alternative LineNumberInputStreamLineNumberReaderStringBufferInputStreamStringReader
java.io.ByteArrayOutputStream ClassThe following method injava.io.ByteArrayOutputStreamwas 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 twotoStringmethods, 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.DataInputStreamhas 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.PrintStreamclass has been superceded by the character-basedjava.io.PrintWriterclass. To discourage its use all the constructors forjava.io.PrintStreamhave been deprecated.
Deprecated Method Alternative PrintStream(OutputStream)PrintWriter(OutputStream)PrintStream(OutputStream, boolean)PrintWriter(OutputStream, boolean)
Related Notes: ThePrintStreamclass has been modified to use the platform's default character encoding and the platform's default line terminator. Thus eachPrintStreamincorporates anOutputStreamWriter, and it passes all characters through this writer to produce bytes for output. Theprintlnmethods use the platform's default line terminator, which is defined by the system propertyline.separatorand is not necessarily a single newline character ('\n'). Bytes and byte arrays written via the existingwritemethods are not passed through the writer.The primary motivation for changing the
PrintStreamclass is that it will makeSystem.outandSystem.errmore useful to people writing Java programs on platforms where the local encoding is something other than ASCII.PrintStreamis, 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.outandSystem.errto be compiled without generating deprecation warnings. Thus programmers just learning Java, or programmers insertingSystem.err.printlncalls 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 newPrintWriterclass, which allows the character encoding to be specified or the default encoding to be accepted. For convenience, thePrintWriterclass provides constructors that take anOutputStreamobject and create an intermediateOutputStreamWriterobject that uses the default encoding.
java.io.StreamTokenizer ClassThe constructor forjava.io.StreamTokenizerthat operates on anInputStreamhas been deprecated in favor of the constructor that operates on aReader. You can still tokenize anInputStreamby 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-2004 Sun Microsystems, Inc. All rights reserved.