java write int,void write(byte[] b, int off, int len)
void write(byte[] b, int off, int len)
描述 (Description)
java.io.PipedOutputStream.write(byte[] b, int off, int len)方法將從offset off開(kāi)始的指定字節(jié)數(shù)組中的len個(gè)字節(jié)寫(xiě)入此管道輸出流。 此方法將阻塞,直到所有字節(jié)都寫(xiě)入輸出流。
聲明 (Declaration)
以下是java.io.PipedOutputStream.write()方法的聲明。public void write(byte[] b, int off, int len)
參數(shù) (Parameters)b - 數(shù)據(jù)。
off - 數(shù)據(jù)中的起始偏移量。
len - 要寫(xiě)入的字節(jié)數(shù)。
返回值 (Return Value)
此方法不返回值。
異常 (Exception)
IOException - 如果發(fā)生I/O錯(cuò)誤。
例子 (Example)
以下示例顯示了java.io.PipedOutputStream.write()方法的用法。package com.iowiki;
import java.io.*;
public class PipedOutputStreamDemo extends PipedInputStream {
public static void main(String[] args) {
byte[] b = {'h', 'e', 'l', 'l', 'o'};
// create a new Piped input and Output Stream
PipedOutputStream out = new PipedOutputStream();
PipedInputStreamDemo in = new PipedInputStreamDemo();
try {
// connect input and output
out.connect(in);
// write something
out.write(b, 0, 3);
// flush the stream
out.flush();
// print what we wrote
for (int i = 0; i < 3; i++) {
System.out.print("" + (char) in.read());
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
讓我們編譯并運(yùn)行上面的程序,這將產(chǎn)生以下結(jié)果 -hel
總結(jié)
以上是生活随笔為你收集整理的java write int,void write(byte[] b, int off, int len)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: gta5抢劫梅利威瑟(第四章.抢劫梅利威
- 下一篇: oracle 挖掘日志,Oracle 日