public abstract class ImageOutputStreamImpl extends ImageInputStreamImpl implements ImageOutputStream
ImageOutputStream接口。
该类旨在减少子类必须实现的方法的数量。
bitOffset, byteOrder, flushedPos, streamPos| Constructor and Description |
|---|
ImageOutputStreamImpl()
构造一个
ImageOutputStreamImpl 。
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
flushBits()
如果位偏移量不为零,则强制当前字节中的剩余位为0,并将流位置提前一位。
|
void |
write(byte[] b)
在当前位置写入一串字节。
|
abstract void |
write(byte[] b, int off, int len)
在当前位置写入一串字节。
|
abstract void |
write(int b)
将当前位置的单个字节写入流。
|
void |
writeBit(int bit)
将由参数的最低有效位给出的单个位写入当前字节位置中当前位偏移量的流。
|
void |
writeBits(long bits, int numBits)
将
bits参数的
numBits最低有效位由左到右的顺序写入到当前字节位置当前位偏移量的流中的位序列。
|
void |
writeBoolean(boolean v)
向流中写入一个
boolean值。
|
void |
writeByte(int v)
将
v的8位低位写入流。
|
void |
writeBytes(String s)
将一个字符串写入输出流。
|
void |
writeChar(int v)
这种方法是
writeShort的同义词。
|
void |
writeChars(char[] c, int off, int len)
在当前位置将一串字符写入流。
|
void |
writeChars(String s)
将一个字符串写入输出流。
|
void |
writeDouble(double v)
将
double值(由四个字节组成)写入输出流。
|
void |
writeDoubles(double[] d, int off, int len)
将当前位置的一系列双精度写入流。
|
void |
writeFloat(float v)
将
float值(由四个字节组成)写入输出流。
|
void |
writeFloats(float[] f, int off, int len)
在当前位置将一系列浮点写入流。
|
void |
writeInt(int v)
将
v的32位写入流。
|
void |
writeInts(int[] i, int off, int len)
在当前位置写入流的序列。
|
void |
writeLong(long v)
将
v的64位写入流。
|
void |
writeLongs(long[] l, int off, int len)
在当前位置写入流的序列。
|
void |
writeShort(int v)
将
v的16位低位写入流。
|
void |
writeShorts(short[] s, int off, int len)
在当前位置写入流的序列。
|
void |
writeUTF(String s)
将两个字节写入的长度信息,以网络字节顺序输出流,接着是
modified UTF-8每个字符的字符串中表示
s 。
|
checkClosed, close, finalize, flush, flushBefore, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, isCached, isCachedFile, isCachedMemory, length, mark, read, read, read, readBit, readBits, readBoolean, readByte, readBytes, readChar, readDouble, readFloat, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUTF, reset, seek, setBitOffset, setByteOrder, skipBytes, skipBytesclone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitflushBeforeclose, flush, getBitOffset, getByteOrder, getFlushedPosition, getStreamPosition, isCached, isCachedFile, isCachedMemory, length, mark, read, read, read, readBit, readBits, readBoolean, readByte, readBytes, readChar, readDouble, readFloat, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedInt, readUnsignedShort, readUTF, reset, seek, setBitOffset, setByteOrder, skipBytes, skipBytespublic abstract void write(int b)
throws IOException
ImageOutputStream
b的24个高位被忽略。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。 实施者可以使用flushBits的方法ImageOutputStreamImpl保证这一点。
write在接口
DataOutput
write在接口
ImageOutputStream
b - 要写入低8位的
int 。
IOException - 如果发生I / O错误。
public void write(byte[] b)
throws IOException
ImageOutputStream
b.length为0,则不写任何内容。
字节b[0]先写,然后字节b[1]等等。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
write在接口
DataOutput
write在接口
ImageOutputStream
b -的阵列
byte s到被写入。
IOException - 如果发生I / O错误。
public abstract void write(byte[] b,
int off,
int len)
throws IOException
ImageOutputStream
len为0,则不写任何内容。
字节b[off]先写,然后字节b[off + 1]等等。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。 实施者可以使用flushBits的方法ImageOutputStreamImpl保证这一点。
write在接口
DataOutput
write中的
ImageOutputStream
b - 要写入的数组
byte 。
off - 数据中的起始偏移量。
len -数量
byte s到写。
IOException - 如果发生I / O错误。
public void writeBoolean(boolean v)
throws IOException
ImageOutputStream
boolean值。
如果v为真,则写入值(byte)1 ;
如果v为false,则写入值(byte)0 。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeBoolean在接口
DataOutput
writeBoolean在接口
ImageOutputStream
v -
boolean 。
IOException - 如果发生I / O错误。
public void writeByte(int v)
throws IOException
ImageOutputStream
v的8位低位写入流。
v的24位v被忽略。
(这意味着writeByte与整数参数完全一样,就像write ))
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeByte在接口
DataOutput
writeByte在接口
ImageOutputStream
v - 包含要写入的字节值的
int 。
IOException - 如果发生I / O错误。
public void writeShort(int v)
throws IOException
ImageOutputStream
v的16位低位写入流。
v的16位v被忽略。
如果流使用网络字节顺序,则按顺序写入的字节为:
(byte)((v >> 8) & 0xff)
(byte)(v & 0xff)
否则写入的字节将为:
(byte)(v & 0xff)
(byte)((v >> 8) & 0xff)
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeShort在接口
DataOutput
writeShort在接口
ImageOutputStream
v - 一个
int要写入的短值的
int 。
IOException - 如果发生I / O错误。
public void writeChar(int v)
throws IOException
ImageOutputStream
writeShort的同义词。
writeChar在接口
DataOutput
writeChar在接口
ImageOutputStream
v - 包含
int写入的char(unsigned short)值的
int 。
IOException - 如果发生I / O错误。
ImageOutputStream.writeShort(int)
public void writeInt(int v)
throws IOException
ImageOutputStream复制
v的32位写入流。
如果流使用网络字节顺序,则按顺序写入的字节为:
(byte)((v >> 24) & 0xff)
(byte)((v >> 16) & 0xff)
(byte)((v >> 8) & 0xff)
(byte)(v & 0xff)
Otheriwse,写入的字节将是:
(byte)(v & 0xff)
(byte)((v >> 8) & 0xff)
(byte)((v >> 16) & 0xff)
(byte)((v >> 24) & 0xff)
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeInt在接口
DataOutput
writeInt在接口
ImageOutputStream
v - 一个
int要写入的值的
int 。
IOException - 如果发生I / O错误。
public void writeLong(long v)
throws IOException
ImageOutputStream
v的64位写入流。
如果流使用网络字节顺序,则按顺序写入的字节为:
(byte)((v >> 56) & 0xff)
(byte)((v >> 48) & 0xff)
(byte)((v >> 40) & 0xff)
(byte)((v >> 32) & 0xff)
(byte)((v >> 24) & 0xff)
(byte)((v >> 16) & 0xff)
(byte)((v >> 8) & 0xff)
(byte)(v & 0xff)
否则写入的字节将为:
(byte)(v & 0xff)
(byte)((v >> 8) & 0xff)
(byte)((v >> 16) & 0xff)
(byte)((v >> 24) & 0xff)
(byte)((v >> 32) & 0xff)
(byte)((v >> 40) & 0xff)
(byte)((v >> 48) & 0xff)
(byte)((v >> 56) & 0xff)
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeLong在接口
DataOutput
writeLong在接口
ImageOutputStream
v - 一个
long要写入的值的
long 。
IOException - 如果发生I / O错误。
public void writeFloat(float v)
throws IOException
ImageOutputStream
float值(由四个字节组成)写入输出流。
它这样做是因为,如果它首先将这个float值到int在完全相同的方式Float.floatToIntBits方法,然后在的完全相同的方式写入的int值writeInt方法。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeFloat在接口
DataOutput
writeFloat在接口
ImageOutputStream
v - 包含要写入的值的
float 。
IOException - 如果发生I / O错误。
public void writeDouble(double v)
throws IOException
ImageOutputStream复制
double值写入输出流,该值由四个字节组成。
它这样做是因为,如果它首先将这个double值到long在完全相同的方式Double.doubleToLongBits方法,然后在完全相同的方式写入长值writeLong方法。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeDouble在接口
DataOutput
writeDouble在接口
ImageOutputStream
v - 一个
double要写入的值的
double 。
IOException - 如果发生I / O错误。
public void writeBytes(String s) throws IOException
ImageOutputStream
s ,为了拍摄,一个字节写入到输出流。
如果s是null ,则抛出一个NullPointerException 。
如果s.length为零,则不会写入任何字节。 否则,字符s[0]先写,然后s[1]等等; 写最后一个字符是s[s.length-1] 。 对于每个字符,写入一个字节,低字节,按照writeByte方法的方式。 字符串中每个字符的高8位被忽略。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeBytes在接口
DataOutput
writeBytes在接口
ImageOutputStream
s - 一个
String要写入的值的
String 。
IOException - 如果发生I / O错误。
public void writeChars(String s) throws IOException
ImageOutputStream复制
s ,为了服用,两个字节被根据当前字节顺序设定写入到输出流中,排序。
如果正在使用网络字节顺序,则首先写入高字节;
否则订单相反。
如果s是null ,则抛出一个NullPointerException 。
如果s.length为零,则不会写入任何字节。 否则,字符s[0]先写,然后s[1]等; 写最后一个字符是s[s.length-1] 。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeChars在接口
DataOutput
writeChars在接口
ImageOutputStream
s - 一个
String要写入的值的
String 。
IOException - 如果发生I / O错误。
public void writeUTF(String s) throws IOException
ImageOutputStream复制
s 。
如果s是null ,则抛出一个NullPointerException 。
根据字符的值,字符串s中的每个字符都将转换为一个,两个或三个字节的组。
如果一个字符c在\u0001到\u007f ,它由一个字节表示:
(byte)c
如果一个字符c是\u0000或者是在\u0080到\u07ff ,那么它由两个字节表示,按照显示的顺序写:
(byte)(0xc0 | (0x1f & (c >> 6))) (byte)(0x80 | (0x3f & c))
如果一个字符c在\u0800到uffff ,那么它由三个字节表示,按照显示的顺序写:
(byte)(0xe0 | (0x0f & (c >> 12))) (byte)(0x80 | (0x3f & (c >> 6))) (byte)(0x80 | (0x3f & c))
首先,以表示的所有字符所需的字节的总数s被计算。 如果这个数字大于65535 ,那么会抛出一个UTFDataFormatException 。 否则,该长度被写入到在完全相同的方式输出流writeShort方法; 之后,写入字符串s中每个字符的一个,两个或三个字节的表示。
当前字节顺序设置被忽略。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
注意:此方法不应用于执行使用标准UTF-8的图像格式,因为此处使用的修改后的UTF-8与标准UTF-8不兼容。
writeUTF在接口
DataOutput
writeUTF在接口
ImageOutputStream
s - 一个
String要写入的值的
String 。
UTFDataFormatException - 如果
UTFDataFormatException的修改的UTF-8
s需要超过65536个字节。
IOException - 如果发生I / O错误。
public void writeShorts(short[] s,
int off,
int len)
throws IOException
ImageOutputStream复制
len为0,则不写任何内容。
短s[off]先写,然后短s[off + 1] ,等等。
流的字节顺序用于确定写入单个字节的顺序。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeShorts在接口
ImageOutputStream
s - 要写入的
short的数组。
off - 数据中的起始偏移量。
len -数量
short s到写。
IOException - 如果发生I / O错误。
public void writeChars(char[] c,
int off,
int len)
throws IOException
ImageOutputStream复制
len为0,则不写任何内容。
char c[off]是先写的,然后是char c[off + 1] ,等等。
流的字节顺序用于确定写入单个字节的顺序。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeChars在接口
ImageOutputStream
c - 要写入的
char的数组。
off - 数据中的起始偏移量。
len -数量
char s到写。
IOException - 如果发生I / O错误。
public void writeInts(int[] i,
int off,
int len)
throws IOException
ImageOutputStream复制
len为0,则不写任何内容。
int i[off]是先写的,然后是int i[off + 1] ,等等。
流的字节顺序用于确定写入单个字节的顺序。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeInts在接口
ImageOutputStream
i - 要写入的
int数组。
off - 数据中的起始偏移量。
len -数量
int s到写。
IOException - 如果发生I / O错误。
public void writeLongs(long[] l,
int off,
int len)
throws IOException
ImageOutputStream复制
len为0,则不写任何内容。
长l[off]是先写的,那么长l[off + 1]等等。
流的字节顺序用于确定写入单个字节的顺序。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeLongs在接口
ImageOutputStream
l - 要写入的
long数组。
off - 数据中的起始偏移量。
len -数量
long s到写。
IOException - 如果发生I / O错误。
public void writeFloats(float[] f,
int off,
int len)
throws IOException
ImageOutputStream
len为0,则不写任何内容。
浮动f[off]先写,然后浮动f[off + 1]等等。
流的字节顺序用于确定写入单个字节的顺序。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeFloats在接口
ImageOutputStream
f - 要写入的数组
float 。
off - 数据中的起始偏移量。
len -数量
float s到写。
IOException - 如果发生I / O错误。
public void writeDoubles(double[] d,
int off,
int len)
throws IOException
ImageOutputStream复制
len为0,则不会写入。
双d[off]先写,然后双d[off + 1]等等。
流的字节顺序用于确定写入单个字节的顺序。
如果流内的位偏移量不为零,则当前字节的剩余部分用0填充并首先写出。 写入后位偏移将为0。
writeDoubles在接口
ImageOutputStream
d -的阵列
doubles s到被写入。
off - 数据中的起始偏移量。
len -数量
double s到写。
IOException - 如果发生I / O错误。
public void writeBit(int bit)
throws IOException
ImageOutputStream复制
如果特定字节的任何位在字节被刷新到目的地时从未被设置,则这些位将自动设置为0。
writeBit在接口
ImageOutputStream
bit -
int最低有效位写入流的int。
IOException - 如果发生I / O错误。
public void writeBits(long bits,
int numBits)
throws IOException
ImageOutputStream复制
numBits所述的至少显著位bits的当前位的当前字节位置内的偏移在左到右的顺序参数,到流中。
上限64 - numBits的参数被忽略。
位偏移提前numBits并减小模8。注意,0的位偏移总是表示字节的最高有效位,并且位数的字节在遇到时按顺序写出。
因此,位写入总是以网络字节顺序有效。
实际流字节顺序设置被忽略。
位数据可以无限期累积到存储器中,直到flushBefore 。 那时候,闪存位置之前的所有位数据将被写入。
如果特定字节的任何位在字节被刷新到目的地时从未被设置,则这些位将自动设置为0。
writeBits在接口
ImageOutputStream
bits - 一个
long要写入的位的
numBits - 1 ,从位置
numBits - 1的位开始到最低有效位。
numBits -一个
int 0和64之间,包括端值。
IOException - 如果发生I / O错误。
protected final void flushBits()
throws IOException
write(int)和write(byte[], int, int)方法的开头应该由子类调用此方法。
IOException - 如果发生I / O错误。
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.