List of usage examples for java.io DataInputStream readInt
public final int readInt() throws IOException
readInt
method of DataInput
. From source file:com.bigdata.dastor.db.RangeSliceReply.java
public static RangeSliceReply read(byte[] body) throws IOException { ByteArrayInputStream bufIn = new ByteArrayInputStream(body); DataInputStream dis = new DataInputStream(bufIn); int rowCount = dis.readInt(); List<Row> rows = new ArrayList<Row>(rowCount); for (int i = 0; i < rowCount; i++) { rows.add(Row.serializer().deserialize(dis)); }/*from ww w .j a va2 s .com*/ return new RangeSliceReply(rows); }
From source file:org.apache.cassandra.db.RangeSliceReply.java
public static RangeSliceReply read(byte[] body, int version) throws IOException { ByteArrayInputStream bufIn = new ByteArrayInputStream(body); DataInputStream dis = new DataInputStream(bufIn); int rowCount = dis.readInt(); List<Row> rows = new ArrayList<Row>(rowCount); for (int i = 0; i < rowCount; i++) { rows.add(Row.serializer().deserialize(dis, version)); }/*from www.j a va 2 s. c o m*/ return new RangeSliceReply(rows); }
From source file:Main.java
/** * Determine whether a file is a ZIP File. *//*from w w w.ja va2 s. c o m*/ public static boolean isZipFile(File file) throws IOException { if (file.isDirectory()) { return false; } if (!file.canRead()) { throw new IOException("Cannot read file " + file.getAbsolutePath()); } if (file.length() < 4) { return false; } DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(file))); int test = in.readInt(); in.close(); return test == 0x504b0304; }
From source file:Main.java
public static int byteArrayToInt(byte[] input) { try {/*www . ja v a 2s.c o m*/ ByteArrayInputStream bis = new ByteArrayInputStream(input); DataInputStream dis = new DataInputStream(bis); int numb = dis.readInt(); dis.close(); return numb; } catch (IOException e) { throw new RuntimeException(e); } }
From source file:Main.java
private static boolean internalIsJPEG(DataInputStream in) throws IOException { boolean result = false; try {/*from w w w . j a v a 2 s . co m*/ int headerBytes = in.readInt(); result = (headerBytes == 0xffd8ffe0); } finally { in.close(); } return result; }
From source file:org.apache.accumulo.core.crypto.CryptoUtils.java
/** * Read the decryption parameters from the DataInputStream *///from ww w .j a va 2 s .c om public static byte[] readParams(DataInputStream in) throws IOException { Objects.requireNonNull(in); int len = in.readInt(); byte[] decryptionParams = new byte[len]; IOUtils.readFully(in, decryptionParams); return decryptionParams; }
From source file:com.opensoc.json.serialization.JSONDecoderHelper.java
public static String getString(DataInputStream data) throws IOException { int strSize = data.readInt(); byte[] bytes = new byte[strSize]; data.read(bytes);/*from w w w. ja va 2 s . co m*/ return new String(bytes); }
From source file:rlVizLib.messaging.BinaryPayload.java
public static String readRawString(DataInputStream DIS) { try {// w w w. j av a 2 s . co m int numBytes = DIS.readInt(); if (numBytes == 0) { return ""; } byte[] theBytes = new byte[numBytes]; DIS.readFully(theBytes); return new String(theBytes); } catch (IOException ex) { Logger.getLogger(BinaryPayload.class.getName()).log(Level.SEVERE, null, ex); } return null; }
From source file:ReadBinaryFile.java
private static Product readMovie(DataInputStream in) { String title = ""; int year = 0; double price = 0.0; try {//from w w w. j av a2s . c o m title = in.readUTF(); year = in.readInt(); price = in.readDouble(); } catch (EOFException e) { return null; } catch (IOException e) { System.out.println("I/O Error"); System.exit(0); } return new Product(title, year, price); }
From source file:TestPipes.java
public static void readData(InputStream is) { DataInputStream in = new DataInputStream(new BufferedInputStream(is)); boolean eof = false; try {/*from www . j a v a 2 s . c om*/ while (!eof) { int iValue = in.readInt(); System.out.println("read value = " + iValue); } } catch (IOException e) { e.printStackTrace(); } System.out.println("End of Data"); }