📜  Java.io.DataOutputStream类

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


介绍

Java.io.DataOutputStream类允许应用程序以可移植的方式将原始Java数据类型写入输出流。然后,应用程序可以使用数据输入流来读回数据。

类声明

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

public class DataOutputStream
   extends FilterOutputStream
      implements DataOutput

领域

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

  • protected int write-这是到目前为止写入数据输出流的字节数。

  • protected OutputStream out-这是要过滤的基础输出流。

类的构造函数

Sr.No. Constructor & Description
1

DataOutputStream(OutputStream out)

This creates a new data output stream to write data to the specified underlying output stream.

类方法

Sr.No. Method & Description
1 void flush()

This method flushes this data output stream.

2 int size()

This method returns the current value of the counter written, the number of bytes written to this data output stream so far.

3 void write(byte[] b, int off, int len)

This method writes len bytes from the specified byte array starting at offset off to the underlying output stream.

4 void write(int b)

This method writes the specified byte (the low eight bits of the argument b) to the underlying output stream.

5 void writeBoolean(boolean v)

This method writes a boolean to the underlying output stream as a 1-byte value.

6 void writeByte(int v)

This method writes out a byte to the underlying output stream as a 1-byte value.

7 void writeBytes(String s)

This method writes out the string to the underlying output stream as a sequence of bytes.

8 void writeChar(int v)

This method writes a char to the underlying output stream as a 2-byte value, high byte first.

9 void writeChars(String s)

This method writes a string to the underlying output stream as a sequence of characters.

10 void writeDouble(double v)

This method converts the double argument to a long using the doubleToLongBits method in class Double, and then writes that long value to the underlying output stream as an 8-byte quantity, high byte first.

11 void writeFloat(float v)

This method converts the float argument to an int using the floatToIntBits method in class Float, and then writes that int value to the underlying output stream as a 4-byte quantity, high byte first.

12 void writeInt(int v)

This method writes an int to the underlying output stream as four bytes, high byte first.

13 void writeLong(long v)

This method writes a long to the underlying output stream as eight bytes, high byte first.

14 void writeShort(int v)

This method writes a short to the underlying output stream as two bytes, high byte first.

15 void writeUTF(String str)

This method writes a string to the underlying output stream using modified UTF-8 encoding in a machine-independent manner.

方法继承

此类从以下类继承方法-

  • Java.io.FilterOutputStream
  • Java对象
  • Java.io.DataOutput