Java DataInputStream.readFully(byte[] b)方法示例
DataInputStream.readFully(byte[] b)
方法的语法如下所示。
public final void readFully(byte[] b) throws IOException
示例
在下面的代码显示如何使用DataInputStream.readFully(byte[] b)
方法。
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
public class Main {
public static void main(String[] args) throws IOException {
InputStream is = new FileInputStream("c:\\test.txt");
DataInputStream dis = new DataInputStream(is);
int length = dis.available();
byte[] buf = new byte[length];
dis.readFully(buf);// @ w w W .Y I i b A I。c o M
for (byte b : buf) {
char c = (char) b;
System.out.print(c);
}
}
}