📌  相关文章
📜  Java.io.DataInputStream类

📅  最后修改于: 2020-11-15 02:40:41             🧑  作者: Mango


介绍

Java.io.DataInputStream类允许应用程序以与机器无关的方式从基础输入流中读取原始Java数据类型。以下是有关DataInputStream的要点-

  • 应用程序使用数据输出流来写入数据,以后可以由数据输入流读取。

  • DataInputStream对于多线程访问不一定是安全的。线程安全是可选的,并且是此类中用户的责任。

类声明

以下是Java.io.DataInputStream类的声明-

public class DataInputStream
   extends FilterInputStream
      implements DataInput

领域

以下是Java.io.DataInputStream类的字段-

  • −中的protected InputStream这是要过滤的输入流。

类的构造函数

Sr.No. Constructor & Description
1

DataInputStream(InputStream in)

This creates a DataInputStream that uses the specified underlying InputStream.

类方法

Sr.No. Method & Description
1 int read(byte[] b)

This method reads some number of bytes from the contained input stream and stores them into the buffer array b

2 int read(byte[] b, int off, int len)

This method reads up to len bytes of data from the contained input stream into an array of bytes.

3 boolean readBoolean()

This method reads one input byte and returns true if that byte is nonzero, false if that byte is zero.

4 byte readByte()

This method reads and returns one input byte.

5 char readChar()

This method reads two input bytes and returns a char value.

6 double readDouble()

This method reads eight input bytes and returns a double value.

7 float readFloat()

This method reads four input bytes and returns a float value.

8 void readFully(byte[] b)

This method reads some bytes from an input stream and stores them into the buffer array b.

9 void readFully(byte[] b, int off, int len)

This method reads len bytes from an input stream.

10 int readInt()

This method reads four input bytes and returns an int value.

11 long readLong()

This method reads eight input bytes and returns a long value.

12 short readShort()

This method reads two input bytes and returns a short value.

13 int readUnsignedByte()

This method reads one input byte, zero-extends it to type int, and returns the result, which is therefore in the range 0 through 255.

14 int readUnsignedShort()

This method reads two input bytes and returns an int value in the range 0 through 65535.

15 String readUTF()

This method reads in a string that has been encoded using a modified UTF-8 format.

16 static String readUTF(DataInput in)

This method 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.

17 int skipBytes(int n)

This method makes an attempt to skip over n bytes of data from the input stream, discarding the skipped bytes.

方法继承

此类从以下类继承方法-

  • Java.io.FilterInputStream
  • Java对象