Alternatives to Deprecated Classes and Methods in java.io

Deprecated Classes in java.io

The following two classes have been deprecated in java.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 both LineNumberInputStream and StringBufferInputStream.

Deprecated Class Alternative
LineNumberInputStream LineNumberReader
StringBufferInputStream StringReader

The java.io.ByteArrayOutputStream Class

The following method in java.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 two toString methods, which allow the caller to specify the character encoding to use to convert bytes to characters or uses the platform's character encoding.

Deprecated Method Alternative
String toString(int hibyte) String toString() or String toString(String enc)

The java.io.DataInputStream Class

The following method in java.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 convertingIOHow to Convert Code that Uses I/O

The java.io.PrintStream Class

The java.io.PrintStream class has been superceded by the character-based java.io.PrintWriter class. To discourage its use all the constructors for java.io.PrintStream have been deprecated.

Deprecated Method Alternative
PrintStream(OutputStream) PrintWriter(OutputStream)
PrintStream(OutputStream, boolean) PrintWriter(OutputStream, boolean)


Related Notes:  The PrintStream class has been modified to use the platform's character encoding and the platform's line terminator. Thus each PrintStream incorporates an OutputStreamWriter, and it passes all characters through this writer to produce bytes for output. The println methods use the platform's line terminator, which is defined by the system property line.separator and is not necessarily a single newline character ('\n').

Bhopal news
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

freelance web designer india ecommerce web developer | Ecommerce web design, software developer india | Web hosting India Windows hosting | India web hosting Windows hosting India | India software developer | web designer india