Java readutf datainputstream io

Java readutf datainputstream io

A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way. An application uses a data output stream to write data that can later be read by a data input stream. DataInputStream is not necessarily safe for multithreaded access. Thread safety is optional and is the responsibility of users of methods in this class.

Field Summary

Fields declared in class java.io.FilterInputStream

Constructor Summary

Method Summary

Reads from the stream in a representation of a Unicode character string encoded in modified UTF-8 format; this string of characters is then returned as a String .

Methods declared in class java.io.FilterInputStream

Methods declared in class java.io.InputStream

Methods declared in class java.lang.Object

Constructor Detail

DataInputStream

Method Detail

read

Reads some number of bytes from the contained input stream and stores them into the buffer array b . The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown. If b is null, a NullPointerException is thrown. If the length of b is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b . The first byte read is stored into element b[0] , the next one into b[1] , and so on. The number of bytes read is, at most, equal to the length of b . Let k be the number of bytes actually read; these bytes will be stored in elements b[0] through b[k-1] , leaving elements b[k] through b[b.length-1] unaffected. The read(b) method has the same effect as:

read

Reads up to len bytes of data from the contained input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read, possibly zero. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown. If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b . The first byte read is stored into element b[off] , the next one into b[off+1] , and so on. The number of bytes read is, at most, equal to len . Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+ k -1] , leaving elements b[off+ k ] through b[off+len-1] unaffected. In every case, elements b[0] through b[off] and elements b[off+len] through b[b.length-1] are unaffected.

Читайте также:  Какую версию php для

readFully

See the general contract of the readFully method of DataInput . Bytes for this operation are read from the contained input stream.

readFully

See the general contract of the readFully method of DataInput . Bytes for this operation are read from the contained input stream.

skipBytes

See the general contract of the skipBytes method of DataInput . Bytes for this operation are read from the contained input stream.

readBoolean

See the general contract of the readBoolean method of DataInput . Bytes for this operation are read from the contained input stream.

readByte

See the general contract of the readByte method of DataInput . Bytes for this operation are read from the contained input stream.

readUnsignedByte

See the general contract of the readUnsignedByte method of DataInput . Bytes for this operation are read from the contained input stream.

readShort

See the general contract of the readShort method of DataInput . Bytes for this operation are read from the contained input stream.

readUnsignedShort

See the general contract of the readUnsignedShort method of DataInput . Bytes for this operation are read from the contained input stream.

readChar

See the general contract of the readChar method of DataInput . Bytes for this operation are read from the contained input stream.

readInt

See the general contract of the readInt method of DataInput . Bytes for this operation are read from the contained input stream.

readLong

See the general contract of the readLong method of DataInput . Bytes for this operation are read from the contained input stream.

readFloat

See the general contract of the readFloat method of DataInput . Bytes for this operation are read from the contained input stream.

readDouble

See the general contract of the readDouble method of DataInput . Bytes for this operation are read from the contained input stream.

readLine

@Deprecated public final String readLine() throws IOException

This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form:

DataInputStream d = new DataInputStream(in);
BufferedReader d = new BufferedReader(new InputStreamReader(in));

See the general contract of the readLine method of DataInput . Bytes for this operation are read from the contained input stream.

readUTF

public final String readUTF() throws IOException

See the general contract of the readUTF method of DataInput . Bytes for this operation are read from the contained input stream.

readUTF

public static final String readUTF​(DataInput in) throws IOException

Reads from the stream in a representation of a Unicode character string encoded in modified UTF-8 format; this string of characters is then returned as a String . The details of the modified UTF-8 representation are exactly the same as for the readUTF method of DataInput .

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

Читайте также:  Kotlin отличие data class

Источник

Class DataInputStream

A data input stream lets an application read primitive Java data types from an underlying input stream in a machine-independent way. An application uses a data output stream to write data that can later be read by a data input stream.

A DataInputStream is not safe for use by multiple concurrent threads. If a DataInputStream is to be used by more than one thread then access to the data input stream should be controlled by appropriate synchronization.

Field Summary

Fields declared in class java.io.FilterInputStream

Constructor Summary

Method Summary

Reads from the stream in a representation of a Unicode character string encoded in modified UTF-8 format; this string of characters is then returned as a String .

Methods declared in class java.io.FilterInputStream

Methods declared in class java.io.InputStream

Methods declared in class java.lang.Object

Constructor Details

DataInputStream

Method Details

read

Reads some number of bytes from the contained input stream and stores them into the buffer array b . The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown. If b is null, a NullPointerException is thrown. If the length of b is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b . The first byte read is stored into element b[0] , the next one into b[1] , and so on. The number of bytes read is, at most, equal to the length of b . Let k be the number of bytes actually read; these bytes will be stored in elements b[0] through b[k-1] , leaving elements b[k] through b[b.length-1] unaffected. The read(b) method has the same effect as:

read

Reads up to len bytes of data from the contained input stream into an array of bytes. An attempt is made to read as many as len bytes, but a smaller number may be read, possibly zero. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown. If len is zero, then no bytes are read and 0 is returned; otherwise, there is an attempt to read at least one byte. If no byte is available because the stream is at end of file, the value -1 is returned; otherwise, at least one byte is read and stored into b . The first byte read is stored into element b[off] , the next one into b[off+1] , and so on. The number of bytes read is, at most, equal to len . Let k be the number of bytes actually read; these bytes will be stored in elements b[off] through b[off+ k -1] , leaving elements b[off+ k ] through b[off+len-1] unaffected. In every case, elements b[0] through b[off] and elements b[off+len] through b[b.length-1] are unaffected.

Читайте также:  Classpath java intellij idea

readFully

See the general contract of the readFully method of DataInput . Bytes for this operation are read from the contained input stream.

readFully

See the general contract of the readFully method of DataInput . Bytes for this operation are read from the contained input stream.

skipBytes

See the general contract of the skipBytes method of DataInput . Bytes for this operation are read from the contained input stream.

readBoolean

See the general contract of the readBoolean method of DataInput . Bytes for this operation are read from the contained input stream.

readByte

See the general contract of the readByte method of DataInput . Bytes for this operation are read from the contained input stream.

readUnsignedByte

See the general contract of the readUnsignedByte method of DataInput . Bytes for this operation are read from the contained input stream.

readShort

See the general contract of the readShort method of DataInput . Bytes for this operation are read from the contained input stream.

readUnsignedShort

See the general contract of the readUnsignedShort method of DataInput . Bytes for this operation are read from the contained input stream.

readChar

See the general contract of the readChar method of DataInput . Bytes for this operation are read from the contained input stream.

readInt

See the general contract of the readInt method of DataInput . Bytes for this operation are read from the contained input stream.

readLong

See the general contract of the readLong method of DataInput . Bytes for this operation are read from the contained input stream.

readFloat

See the general contract of the readFloat method of DataInput . Bytes for this operation are read from the contained input stream.

readDouble

See the general contract of the readDouble method of DataInput . Bytes for this operation are read from the contained input stream.

readLine

This method does not properly convert bytes to characters. As of JDK 1.1, the preferred way to read lines of text is via the BufferedReader.readLine() method. Programs that use the DataInputStream class to read lines can be converted to use the BufferedReader class by replacing code of the form:

DataInputStream d = new DataInputStream(in);
BufferedReader d = new BufferedReader(new InputStreamReader(in));

See the general contract of the readLine method of DataInput . Bytes for this operation are read from the contained input stream.

readUTF

See the general contract of the readUTF method of DataInput . Bytes for this operation are read from the contained input stream.

readUTF

Reads from the stream in a representation of a Unicode character string encoded in modified UTF-8 format; this string of characters is then returned as a String . The details of the modified UTF-8 representation are exactly the same as for the readUTF method of DataInput .

Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.

Источник

Оцените статью