当前位置: 首页>>代码示例>>Java>>正文


Java DataInputStream.readFully方法代码示例

本文整理汇总了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);
  }
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:21,代码来源:PRNGFixes.java

示例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);
    }
}
 
开发者ID:mithrilcoin-io,项目名称:EosCommander,代码行数:21,代码来源:PRNGFixes.java

示例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]);
        }
    }
}
 
开发者ID:addertheblack,项目名称:myster,代码行数:26,代码来源:RequestDirThread.java

示例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();

}
 
开发者ID:axlecho,项目名称:tuxguitar,代码行数:20,代码来源:ModelByteBuffer.java

示例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) { }
    }
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:25,代码来源:BinSerializer.java

示例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]);
  }
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:37,代码来源:ADC2Module.java

示例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!");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:CustomLoader.java

示例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;
}
 
开发者ID:addertheblack,项目名称:myster,代码行数:13,代码来源:FileSenderThread.java

示例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);
	}
}
 
开发者ID:rafjordao,项目名称:Nird2,代码行数:12,代码来源:LinuxSecureRandomSpi.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:MessagesHandlerTest.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:Code.java

示例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);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ClassfileBytecode.java

示例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);
}
 
开发者ID:gahana,项目名称:edge-jwt-sample,代码行数:11,代码来源:JWTUtil.java

示例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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:BinaryConstantPool.java

示例15: readInfoSizeBlock

import java.io.DataInputStream; //导入方法依赖的package包/类
protected void readInfoSizeBlock(DataInputStream in) throws IOException {
  ADC2Utils.readBlockHeader(in, "Info Size");
  in.readFully(new byte[4]);
}
 
开发者ID:ajmath,项目名称:VASSAL-src,代码行数:5,代码来源:ADC2Module.java


注:本文中的java.io.DataInputStream.readFully方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。