本文整理了Java中java.io.DataInputStream.<init>()
方法的一些代码示例,展示了DataInputStream.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。DataInputStream.<init>()
方法的具体详情如下:
包路径:java.io.DataInputStream
类名称:DataInputStream
方法名:<init>
[英]Constructs a new DataInputStream on the InputStream in. All reads are then filtered through this stream. Note that data read by this stream is not in a human readable format and was most likely created by a DataOutputStream.
Warning: passing a null source creates an invalid DataInputStream. All operations on such a stream will fail.
[中]在中的InputStream上构造新的DataInputStream。然后通过该流过滤所有读取。请注意,此流读取的数据不是人类可读的格式,很可能是由DataOutputStream创建的。
警告:传递空源将创建无效的DataInputStream。此类流上的所有操作都将失败。
代码示例来源:origin: jenkinsci/jenkins
public Connection(InputStream in, OutputStream out) {
this.in = in;
this.out = out;
this.din = new DataInputStream(in);
this.dout = new DataOutputStream(out);
}
代码示例来源:origin: neo4j/neo4j
public PackedInputArray( byte[] bytes )
{
this.bytes = new ByteArrayInputStream( bytes );
this.data = new DataInputStream( this.bytes );
}
代码示例来源:origin: stackoverflow.com
import java.io.DataInputStream;
DataInputStream dis = new DataInputStream(System.in);
int i = dis.readInt();
代码示例来源:origin: google/j2objc
private boolean checkMagic(File file, long magic) throws IOException {
DataInputStream in = new DataInputStream(new FileInputStream(file));
try {
int m = in.readInt();
return magic == m;
} finally {
in.close();
}
}
代码示例来源:origin: redisson/redisson
/**
* Main method.
*
* @param args <code>args[0]</code> is the class file name.
*/
public static void main(String[] args) throws Exception {
if (args.length != 1) {
System.err.println("Usage: java Dump <class file name>");
return;
}
DataInputStream in = new DataInputStream(
new FileInputStream(args[0]));
ClassFile w = new ClassFile(in);
PrintWriter out = new PrintWriter(System.out, true);
out.println("*** constant pool ***");
w.getConstPool().print(out);
out.println();
out.println("*** members ***");
ClassFilePrinter.print(w, out);
}
}
代码示例来源:origin: marytts/marytts
public void read(String binaryFile) throws IOException {
DataInputStream dis = new DataInputStream(new FileInputStream(new File(binaryFile)));
read(dis);
}
代码示例来源:origin: stackoverflow.com
public static void main(String... args) throws IOException {
final String filename = args[0];
final File file = new File(filename);
DataInputStream dis = new DataInputStream(new FileInputStream(file));
byte[] bytes = new byte[(int) file.length()];
dis.readFully(bytes);
System.out.println("Average latency " + latency + " ns. Bandwidth " + bandwidth + " MB/s.");
代码示例来源:origin: wildfly/wildfly
public Connection(Socket sock) throws IOException {
this.sock=sock;
this.in=new DataInputStream(sock.getInputStream());
this.out=new DataOutputStream(sock.getOutputStream());
}
代码示例来源:origin: stackoverflow.com
writeFile("numbers2.bin", nums);
long time = System.currentTimeMillis() - start;
System.out.println("Took "+time+" secs to sort "+nums.length+" numbers.");
DataInputStream dis = new DataInputStream(new BufferedInputStream(new FileInputStream(filename), 64*1024));
int len = dis.readInt();
int[] ints = new int[len];
for(int i=0;i<len;i++)
ints[i] = dis.readInt();
return ints;
DataOutputStream dos = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(name), 64*1024));
dos.writeInt(numbers.length);
for (int number : numbers)
代码示例来源:origin: stackoverflow.com
byte[] test = new byte[] {0, 0, 1, 0, 0, 0, 1, 1, 8, 9};
DataInputStream stream = new DataInputStream(new ByteArrayInputStream(test));
int value0 = stream.readInt();
int value1 = stream.readInt();
byte value2 = stream.readByte();
byte value3 = stream.readByte();
stream.close();
System.out.println(value0 + " " + value1 + " " + value2 + " " + value3);
代码示例来源:origin: stackoverflow.com
import java.io.*;
public class ClassVersionChecker {
public static void main(String[] args) throws IOException {
for (int i = 0; i < args.length; i++)
checkClassVersion(args[i]);
}
private static void checkClassVersion(String filename)
throws IOException
{
DataInputStream in = new DataInputStream
(new FileInputStream(filename));
int magic = in.readInt();
if(magic != 0xcafebabe) {
System.out.println(filename + " is not a valid class!");;
}
int minor = in.readUnsignedShort();
int major = in.readUnsignedShort();
System.out.println(filename + ": " + major + " . " + minor);
in.close();
}
}
代码示例来源:origin: aragozin/jvm-tools
void rewind() {
readOffset = 0;
if (useBackingFile) {
try {
if (readStream != null) {
readStream.close();
}
readStream = new DataInputStream(new BufferedInputStream(new FileInputStream(backingFile), buffer.length * 8));
readStreamClosed = false;
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
代码示例来源:origin: alibaba/canal
public void seek(long seekBytes) throws FileNotFoundException, IOException, InterruptedException {
fileInput = new FileInputStream(file);
fileChannel = fileInput.getChannel();
try {
fileChannel.position(seekBytes);
} catch (ClosedByInterruptException e) {
throw new InterruptedException();
}
bufferedInput = new BufferedInputStream(fileInput, size);
dataInput = new DataInputStream(bufferedInput);
offset = seekBytes;
}
代码示例来源:origin: google/ExoPlayer
private static void doTestSerializationRoundTrip(DownloadAction action) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
DataOutputStream output = new DataOutputStream(out);
DownloadAction.serializeToStream(action, output);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
DataInputStream input = new DataInputStream(in);
DownloadAction action2 =
DownloadAction.deserializeFromStream(
new DownloadAction.Deserializer[] {ProgressiveDownloadAction.DESERIALIZER}, input);
assertThat(action2).isEqualTo(action);
}
代码示例来源:origin: stackoverflow.com
music=new byte[(int) file.length()];//size & length of the file
InputStream is = new FileInputStream (file);
BufferedInputStream bis = new BufferedInputStream (is, 8000);
DataInputStream dis = new DataInputStream (bis); // Create a DataInputStream to read the audio data from the saved file
int i = 0; // Read the file into the "music" array
while (dis.available() > 0)
{
music[i] = dis.readByte(); // This assignment does not reverse the order
i++;
}
dis.close(); // Close the input stream
代码示例来源:origin: apache/incubator-pinot
private void loadCreationMeta(File crcFile)
throws IOException {
if (crcFile.exists()) {
final DataInputStream ds = new DataInputStream(new FileInputStream(crcFile));
_crc = ds.readLong();
_creationTime = ds.readLong();
ds.close();
}
}
代码示例来源:origin: stackoverflow.com
...
byte[] imgDataBa = new byte[(int)imgFile.length()];
DataInputStream dataIs = new DataInputStream(new FileInputStream(imgFile));
dataIs.readFully(imgDataBa);
...
代码示例来源:origin: apache/zookeeper
@Override
public void revalidateSession(QuorumPacket qp, LearnerHandler learnerHandler) throws IOException {
ByteArrayInputStream bis = new ByteArrayInputStream(qp.getData());
DataInputStream dis = new DataInputStream(bis);
long id = dis.readLong();
int to = dis.readInt();
synchronized (revalidateSessionLock) {
pendingRevalidations.add(new Revalidation(id, to, learnerHandler));
Learner learner = zks.getLearner();
if (learner != null) {
learner.writePacket(qp, true);
}
}
}
代码示例来源:origin: apache/ignite
/**
* Deserialization of Hadoop Writable object.
*
* @param writable Writable object to deserialize to.
* @param bytes byte array to deserialize.
*/
public static void deserialize(Writable writable, byte[] bytes) throws IOException {
DataInputStream dataIn = new DataInputStream(new ByteArrayInputStream(bytes));
writable.readFields(dataIn);
dataIn.close();
}
代码示例来源:origin: apache/kylin
@Test
public void testSerialize() throws IOException {
AppendTrieDictionaryBuilder builder = createBuilder();
AppendTrieDictionary dict = builder.build(0);
ByteArrayOutputStream bout = new ByteArrayOutputStream();
DataOutputStream dataout = new DataOutputStream(bout);
dict.write(dataout);
dataout.close();
ByteArrayInputStream bin = new ByteArrayInputStream(bout.toByteArray());
DataInputStream datain = new DataInputStream(bin);
assertNull(new Path(datain.readUTF()).toUri().getScheme());
datain.close();
}
内容来源于网络,如有侵权,请联系作者删除!