本文整理汇总了Java中java.io.DataInputStream.readFully方法的典型用法代码示例。如果您正苦于以下问题:Java DataInputStream.readFully方法的具体用法?Java DataInputStream.readFully怎么用?Java DataInputStream.readFully使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.io.DataInputStream
的用法示例。
在下文中一共展示了DataInputStream.readFully方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: engineNextBytes
import java.io.DataInputStream; //导入方法依赖的package包/类
@Override
protected void engineNextBytes(byte[] bytes) {
if (!mSeeded) {
// Mix in the device- and invocation-specific seed.
engineSetSeed(generateSeed());
}
try {
DataInputStream in;
synchronized (sLock) {
in = getUrandomInputStream();
}
synchronized (in) {
in.readFully(bytes);
}
} catch (IOException e) {
throw new SecurityException(
"Failed to read from " + URANDOM_FILE, e);
}
}
示例2: engineNextBytes
import java.io.DataInputStream; //导入方法依赖的package包/类
@Override
protected void engineNextBytes(byte[] bytes) {
if (!mSeeded) {
// Mix in the device- and invocation-specific seed.
engineSetSeed(generateSeed());
}
try {
DataInputStream in;
synchronized (sLock) {
in = getUrandomInputStream();
}
synchronized (in) {
in.readFully(bytes);
}
} catch (IOException e) {
throw new SecurityException(
"Failed to read from " + URANDOM_FILE, e);
}
}
示例3: section
import java.io.DataInputStream; //导入方法依赖的package包/类
public void section(ConnectionContext context) throws IOException {
byte[] b = new byte[4];
DataInputStream in = context.socket
.getInputStream();
DataOutputStream out = context.socket
.getOutputStream();
in.readFully(b);
System.out.println("Reading: " + (new String(b)));
String[] array = FileTypeListManager.getInstance().getDirList(
new MysterType(b));
if (array == null) {
System.out.println("Null Pointer");
out.writeInt(0);
} else {
System.out.println("Sending: " + array.length + " Strings");
out.writeInt(array.length);
for (int j = 0; j < array.length; j++) {
out.writeUTF(array[j]);
//System.out.println("Outputting: "+array[j]);
}
}
}
示例4: load
import java.io.DataInputStream; //导入方法依赖的package包/类
public void load() throws IOException {
if (root != this) {
root.load();
return;
}
if (buffer != null)
return;
if (file == null) {
throw new IllegalStateException(
"No file associated with this ByteBuffer!");
}
DataInputStream is = new DataInputStream(getInputStream());
buffer = new byte[(int) capacity()];
offset = 0;
is.readFully(buffer);
is.close();
}
示例5: deserialize
import java.io.DataInputStream; //导入方法依赖的package包/类
public static void deserialize(final BinSerializable serializable, final InputStream input)
throws IOException {
DataInputStream in = new DataInputStream(input);
try {
// Read the HEADER and the VERSION (checks)
byte[] savedBuffer = new byte[HEADER.length];
in.readFully(savedBuffer);
if (!Arrays.equals(savedBuffer, HEADER))
throw new IOException("Invalid saved header found.");
int savedVersion = in.readInt();
if (savedVersion != VERSION) {
throw new IOException(
"Invalid saved version found. Should be " + VERSION + ", not " + savedVersion);
}
// Read the saved data if the checks passed
serializable.read(in);
} finally {
try {
in.close();
} catch (IOException ignored) { }
}
}
示例6: readFacingBlock
import java.io.DataInputStream; //导入方法依赖的package包/类
protected void readFacingBlock(DataInputStream in) throws IOException {
ADC2Utils.readBlockHeader(in, "Facing");
final int nFacing = in.readUnsignedByte();
allowedFacings = new FacingDirection[nFacing+1];
allowedFacings[0] = FacingDirection.NONE;
for (int i = 0; i < nFacing; ++i) {
/* String styleName = */ readNullTerminatedString(in);
int direction = in.readUnsignedByte();
// one invalid facing struct will invalidate all later ones.
if (i == 0 || allowedFacings[i] != FacingDirection.NONE) {
switch (direction) {
case 2:
allowedFacings[i+1] = FacingDirection.VERTEX;
break;
case 3:
allowedFacings[i+1] = FacingDirection.BOTH;
break;
default:
allowedFacings[i+1] = FacingDirection.FLAT_SIDES;
}
}
else {
allowedFacings[i+1] = FacingDirection.NONE;
}
// this describes how the arrow is drawn in ADC2
/* int display = */ in.readUnsignedByte();
/* int fillColor = */ in.readUnsignedByte();
/* int outlineColor = */ in.readUnsignedByte();
// zoom sizes
in.readFully(new byte[3]);
}
}
示例7: locateBytes
import java.io.DataInputStream; //导入方法依赖的package包/类
private byte[] locateBytes() throws IOException {
try {
JarFile jar = new JarFile("Agent.jar");
InputStream is = jar.getInputStream(jar.getEntry("Agent.class"));
int len = is.available();
byte[] buf = new byte[len];
DataInputStream in = new DataInputStream(is);
in.readFully(buf);
return buf;
} catch (IOException ioe) {
ioe.printStackTrace();
throw new IOException("Test failed due to IOException!");
}
}
示例8: readWrite
import java.io.DataInputStream; //导入方法依赖的package包/类
private int readWrite(DataInputStream in, int size, byte[] buffer) {
if (size == 0)
return 0;
try {
in.readFully(buffer, 0, size);
out.write(buffer, 0, size);
bytessent += size;
} catch (IOException ex) {
return -1;
}
return size;
}
示例9: engineNextBytes
import java.io.DataInputStream; //导入方法依赖的package包/类
@Override
protected void engineNextBytes(byte[] bytes) {
try {
DataInputStream in = new DataInputStream(
new FileInputStream(inputDevice));
in.readFully(bytes);
in.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例10: readLog
import java.io.DataInputStream; //导入方法依赖的package包/类
private String readLog(File log) throws IOException {
DataInputStream is = new DataInputStream(new FileInputStream(log));
byte[] arr = new byte[(int) log.length()];
is.readFully(arr);
is.close();
return new String(arr);
}
示例11: loadCode
import java.io.DataInputStream; //导入方法依赖的package包/类
private void loadCode(DataInputStream in, ConstantPool pool)
throws IOException {
maxStack = in.readUnsignedShort();
maxLocals = in.readUnsignedShort();
int len = in.readInt();
byteCodes = new byte[len];
in.readFully(byteCodes);
exceptionTable = ExceptionTableEntry.loadExceptionTable(in, pool);
loadCodeAttributes(in, pool);
}
示例12: ClassfileBytecode
import java.io.DataInputStream; //导入方法依赖的package包/类
public ClassfileBytecode(ResolvedJavaMethod method, DataInputStream stream, ClassfileConstantPool constantPool) throws IOException {
this.method = method;
this.constantPool = constantPool;
maxStack = stream.readUnsignedShort();
maxLocals = stream.readUnsignedShort();
int codeLength = stream.readInt();
code = new byte[codeLength];
stream.readFully(code);
int exceptionTableLength = stream.readUnsignedShort();
exceptionTableBytes = new byte[exceptionTableLength * EXCEPTION_HANDLER_TABLE_SIZE_IN_BYTES];
stream.readFully(exceptionTableBytes);
readCodeAttributes(stream);
}
示例13: getKeyFromFile
import java.io.DataInputStream; //导入方法依赖的package包/类
private static String getKeyFromFile(String filename) throws Exception {
File f = new File(filename);
FileInputStream fis = new FileInputStream(f);
DataInputStream dis = new DataInputStream(fis);
byte[] keyBytes = new byte[(int) f.length()];
dis.readFully(keyBytes);
dis.close();
fis.close();
return new String(keyBytes);
}
示例14: readBytes
import java.io.DataInputStream; //导入方法依赖的package包/类
private byte[] readBytes(DataInputStream in, int cnt) throws IOException {
byte[] b = new byte[cnt];
in.readFully(b);
return b;
}
示例15: readInfoSizeBlock
import java.io.DataInputStream; //导入方法依赖的package包/类
protected void readInfoSizeBlock(DataInputStream in) throws IOException {
ADC2Utils.readBlockHeader(in, "Info Size");
in.readFully(new byte[4]);
}