public class DataOutputStream extends FilterOutputStream implements DataOutput
DataInputStream
| Modifier and Type | Field and Description |
|---|---|
protected int |
written
写入到数据输出流的字节数,到目前为止。
|
out| Constructor and Description |
|---|
DataOutputStream(OutputStream out)
创建一个新的数据输出流,将数据写入到指定的基本输出流中。
|
| Modifier and Type | Method and Description |
|---|---|
void |
flush()
刷新数据输出流。
|
int |
size()
返回柜台
written电流值,这个数据写入输出流的字节数为止。
|
void |
write(byte[] b, int off, int len)
写
len字节指定字节数组中的起始偏移量
off当前输出流。
|
void |
write(int b)
将指定的字节(论证
b的低八位)的底层输出流。
|
void |
writeBoolean(boolean v)
写一个
boolean当前输出流作为一个字节的值。
|
void |
writeByte(int v)
写了
byte当前输出流作为一个字节的值。
|
void |
writeBytes(String s)
将字符串写入到基础的输出流作为字节序列。
|
void |
writeChar(int v)
写一个
char当前输出流作为一个双字节值,高字节优先。
|
void |
writeChars(String s)
将一个字符串写入底层输出流,作为一个字符序列。
|
void |
writeDouble(double v)
将双参数到一个
long使用
doubleToLongBits方法在类
Double,然后写道,
long值基本的输出流的字节的数量,高字节优先。
|
void |
writeFloat(float v)
将浮点型参数的
int使用
floatToIntBits方法在类
Float,然后写道,
int值基本为4字节输出流量,高字节优先。
|
void |
writeInt(int v)
写一个
int当前输出流为四个字节,高字节优先。
|
void |
writeLong(long v)
写一个
long当前输出流为八个字节,高字节优先。
|
void |
writeShort(int v)
写一个
short当前输出流的两个字节,高字节优先。
|
void |
writeUTF(String str)
一个字符串写入到输出流的潜在使用在一个机器无关的方式
modified UTF-8编码。
|
close, writeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitwritepublic DataOutputStream(OutputStream out)
written设置为零。
out -底层输出流被保存供以后使用。
FilterOutputStream.out
public void write(int b)
throws IOException
b的低八位)的底层输出流。如果没有异常被抛出,反
written递增
1。
实现的方法OutputStream write。
write 接口
DataOutput
write 方法重写,继承类
FilterOutputStream
b -
byte要写。
IOException如果I/O错误发生。
FilterOutputStream.out
public void write(byte[] b,
int off,
int len)
throws IOException
len字节指定字节数组中的起始偏移量
off当前输出流。如果没有异常被抛出,反
written递增
len。
write 接口
DataOutput
write 方法重写,继承类
FilterOutputStream
b -数据。
off的起始偏移量的数据。
len -字节数写。
IOException如果I/O错误发生。
FilterOutputStream.out
public void flush()
throws IOException
对DataOutputStream的flush方法调用的底层输出流的flush方法。
flush 接口
Flushable
flush 方法重写,继承类
FilterOutputStream
IOException如果I/O错误发生。
FilterOutputStream.out,
OutputStream.flush()
public final void writeBoolean(boolean v)
throws IOException
boolean当前输出流作为一个字节的值。价值
true写出来的价值
(byte)1;价值
false写出来的价值
(byte)0。如果没有异常被抛出,反
written递增
1。
writeBoolean 接口
DataOutput
v -
boolean值被写入。
IOException如果I/O错误发生。
FilterOutputStream.out
public final void writeByte(int v)
throws IOException
byte当前输出流作为一个字节的值。如果没有异常被抛出,反
written递增
1。
writeByte 接口
DataOutput
v -
byte值被写入。
IOException如果I/O错误发生。
FilterOutputStream.out
public final void writeShort(int v)
throws IOException
short当前输出流的两个字节,高字节优先。如果没有异常被抛出,反
written递增
2。
writeShort 接口
DataOutput
v -
short要写。
IOException如果I/O错误发生。
FilterOutputStream.out
public final void writeChar(int v)
throws IOException
char当前输出流作为一个双字节值,高字节优先。如果没有异常被抛出,反
written递增
2。
writeChar 接口
DataOutput
v -
char值被写入。
IOException如果I/O错误发生。
FilterOutputStream.out
public final void writeInt(int v)
throws IOException
int当前输出流为四个字节,高字节优先。如果没有异常被抛出,反
written递增
4。
writeInt 接口
DataOutput
v -
int要写。
IOException如果I/O错误发生。
FilterOutputStream.out
public final void writeLong(long v)
throws IOException
long当前输出流为八个字节,高字节优先。在不引发异常,反
written递增
8。
writeLong 接口
DataOutput
v -
long要写。
IOException如果I/O错误发生。
FilterOutputStream.out
public final void writeFloat(float v)
throws IOException
int使用
floatToIntBits方法在类
Float,然后写道,
int值基本为4字节输出流量,高字节优先。如果没有异常被抛出,反
written递增
4。
writeFloat 接口
DataOutput
v -
float值被写入。
IOException如果I/O错误发生。
FilterOutputStream.out,
Float.floatToIntBits(float)
public final void writeDouble(double v)
throws IOException
long使用
doubleToLongBits方法在类
Double,然后写道,
long值基本的输出流的字节的数量,高字节优先。如果没有异常被抛出,反
written递增
8。
writeDouble 接口
DataOutput
v -
double值被写入。
IOException如果I/O错误发生。
FilterOutputStream.out,
Double.doubleToLongBits(double)
public final void writeBytes(String s) throws IOException
written递增的
s长度。
writeBytes 接口
DataOutput
s -一个字符串的字节被写入。
IOException如果I/O错误发生。
FilterOutputStream.out
public final void writeChars(String s) throws IOException
writeChar。如果没有异常被抛出,反
written加两
s长度。
writeChars 接口
DataOutput
s -
String值被写入。
IOException如果I/O错误发生。
writeChar(int),
FilterOutputStream.out
public final void writeUTF(String str) throws IOException
首先,两个字节被写入到输出流的方法,如writeShort给字节数跟随。此值是实际写出来的字节数,而不是字符串的长度。以下的长度,字符串的每个字符输出序列,使用修改后的UTF-8字符编码。如果没有异常被抛出,反written递增写入输出流的字节总数。这将是至少两加str长度,最多二加三倍的长度str。
writeUTF 接口
DataOutput
str -字符串被写入。
IOException如果I/O错误发生。
public final int size()
written电流值,这个数据写入输出流的字节数为止。如果计数器溢出,则将包裹integer.max_value。
written字段的值。
written
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.