Example usage for java.io DataInput readFully

List of usage examples for java.io DataInput readFully

Introduction

In this page you can find the example usage for java.io DataInput readFully.

Prototype

void readFully(byte b[]) throws IOException;

Source Link

Document

Reads some bytes from an input stream and stores them into the buffer array b .

Usage

From source file:backup.store.BackupUtil.java

public static String readShortString(DataInput in) throws IOException {
    byte[] buf = new byte[in.readShort()];
    in.readFully(buf);
    return new String(buf);
}

From source file:com.cloud.utils.crypt.RSAHelper.java

private static byte[] readElement(DataInput dis) throws IOException {
    int len = dis.readInt();
    byte[] buf = new byte[len];
    dis.readFully(buf);
    return buf;//from   w  w w  .  j a  va 2s  .com
}

From source file:net.darkmist.alib.io.Slurp.java

public static byte[] slurp(DataInput din, int amount) throws IOException {
    byte data[] = new byte[amount];

    din.readFully(data);
    return data;/* w  w w  .  j ava 2s . c  o  m*/
}

From source file:com.bah.culvert.util.Bytes.java

/**
 * Read a a byte [] written with {@link #writeByteArray(DataOutput, byte[])}
 * @param input to read from//from   ww  w .  j av a2  s .  co m
 * @return the first element in the input stream as a byte[]
 * @throws IOException on failure to read
 */
public static byte[] readByteArray(DataInput input) throws IOException {
    byte[] bytes = new byte[input.readInt()];
    input.readFully(bytes);
    return bytes;
}

From source file:com.wsc.myexample.decisionForest.MyDataset.java

public static String readString(DataInput in) throws IOException {
    int length = in.readInt();
    if (length == -1)
        return null;
    byte[] buffer = new byte[length];
    in.readFully(buffer); // could/should use readFully(buffer,0,length)?
    return new String(buffer, "UTF-8");
}

From source file:io.mycat.util.ByteBufferUtil.java

public static byte[] readBytes(DataInput in, int length) throws IOException {
    assert length > 0 : "length is not > 0: " + length;
    byte[] bytes = new byte[length];
    in.readFully(bytes);
    return bytes;
}

From source file:com.bigdata.dastor.utils.FBUtilities.java

public static void deserialize(TDeserializer deserializer, TBase struct, DataInput in) throws IOException {
    assert deserializer != null;
    assert struct != null;
    assert in != null;
    byte[] bytes = new byte[in.readInt()];
    in.readFully(bytes);
    try {//from  ww w  .  j ava  2s . co m
        deserializer.deserialize(struct, bytes);
    } catch (TException ex) {
        throw new IOException(ex);
    }
}

From source file:edu.umn.cs.spatialHadoop.core.JTSShape.java

@Override
public void readFields(DataInput in) throws IOException {
    try {/* ww w . j av a  2  s  .co m*/
        byte[] wkb = new byte[in.readInt()];
        in.readFully(wkb);
        geom = wkbReader.read(wkb);
    } catch (ParseException e) {
        e.printStackTrace();
        throw new IOException(e);
    }
}

From source file:edu.umn.cs.spatialHadoop.core.OGCESRIShape.java

@Override
public void readFields(DataInput in) throws IOException {
    int size = in.readInt();
    byte[] bytes = new byte[size];
    in.readFully(bytes);
    geom = OGCGeometry.fromBinary(ByteBuffer.wrap(bytes));
}

From source file:cosmos.records.impl.MapRecord.java

@Override
public void readFields(DataInput in) throws IOException {
    this.docId = Text.readString(in);

    final int cvLength = WritableUtils.readVInt(in);
    final byte[] cvBytes = new byte[cvLength];
    in.readFully(cvBytes);

    this.docVisibility = new ColumnVisibility(cvBytes);

    final int entryCount = WritableUtils.readVInt(in);
    this.document = Maps.newHashMapWithExpectedSize(entryCount);

    for (int i = 0; i < entryCount; i++) {

        this.document.put(Column.recreate(in), RecordValue.recreate(in));
    }/*from w  ww. java 2s.  c  om*/
}