Example usage for java.io DataInput readUTF

List of usage examples for java.io DataInput readUTF

Introduction

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

Prototype

String readUTF() throws IOException;

Source Link

Document

Reads in a string that has been encoded using a modified UTF-8 format.

Usage

From source file:cn.ac.ict.htc.tools.ArrayListWritable.java

/**
 * Deserializes the array.//from  w  w  w .jav  a  2  s  .c o m
 *
 * @param in source for raw byte representation
 */
@SuppressWarnings("unchecked")
public void readFields(DataInput in) throws IOException {
    this.clear();

    int numFields = in.readInt();
    if (numFields == 0)
        return;
    String className = in.readUTF();
    E obj;
    try {
        Class<E> c = (Class<E>) Class.forName(className);
        for (int i = 0; i < numFields; i++) {
            obj = (E) c.newInstance();
            obj.readFields(in);
            this.add(obj);
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:com.aliyun.openservices.tablestore.hadoop.Endpoint.java

@Override
public void readFields(DataInput in) throws IOException {
    byte tag = in.readByte();
    if (tag != WritableConsts.ENDPOINT) {
        throw new IOException("broken input stream");
    }/*from  ww  w . j a  va2  s.  co  m*/
    endpoint = null;
    instance = null;
    endpoint = in.readUTF();
    instance = in.readUTF();
}

From source file:com.aliyun.openservices.tablestore.hadoop.Credential.java

@Override
public void readFields(DataInput in) throws IOException {
    byte tag = in.readByte();
    if (tag != WritableConsts.CREDENTIAL) {
        throw new IOException("broken input stream");
    }//from   w  w w . j a v a2s .  c o  m
    accessKeyId = null;
    accessKeySecret = null;
    securityToken = null;
    accessKeyId = in.readUTF();
    accessKeySecret = in.readUTF();
    byte tagSecurityToken = nextTag(in);
    if (tagSecurityToken == WritableConsts.CREDENTIAL_SECURITY_TOKEN) {
        securityToken = in.readUTF();
    }
}

From source file:edu.umn.cs.spatialHadoop.osm.OSMEdge.java

@Override
public void readFields(DataInput in) throws IOException {
    edgeId = in.readLong();//from w  w  w  .  j av a 2s . com
    nodeId1 = in.readLong();
    lat1 = in.readDouble();
    lon1 = in.readDouble();
    nodeId2 = in.readLong();
    lat2 = in.readDouble();
    lon2 = in.readDouble();
    wayId = in.readLong();
    tags = in.readUTF();
}

From source file:com.kylinolap.dict.lookup.SnapshotTable.java

void readData(DataInput in) throws IOException {
    int rowNum = in.readInt();
    rows = new ArrayList<String[]>(rowNum);
    if (rowNum > 0) {
        int n = in.readInt();
        for (int i = 0; i < rowNum; i++) {
            String[] row = new String[n];
            rows.add(row);//from   w ww. ja v  a 2  s.c om
            for (int j = 0; j < n; j++) {
                row[j] = in.readUTF();
            }
        }
    }
}

From source file:com.mobicage.rogerthat.registration.ContentBrandingRegistrationWizard.java

@Override
public void readFromPickle(int version, DataInput in) throws IOException, PickleException {
    T.UI();/* w  ww . jav a 2s  . co m*/
    boolean set = in.readBoolean();
    if (set)
        mCredentials = new Credentials(new Pickle(in.readInt(), in));
    set = in.readBoolean();
    mEmail = set ? in.readUTF() : null;
    mTimestamp = in.readLong();
    mRegistrationId = in.readUTF();
    mInstallationId = in.readUTF();
    mDeviceId = in.readUTF();
}

From source file:edu.umd.cloud9.collection.wikipedia.WikipediaPage.java

/**
 * Serializes this object.//from w  ww .  j  a va  2  s  .c o  m
 */
public void readFields(DataInput in) throws IOException {
    int length = WritableUtils.readVInt(in);
    byte[] bytes = new byte[length];
    in.readFully(bytes, 0, length);
    WikipediaPage.readPage(this, new String(bytes));
    language = in.readUTF();
}

From source file:cn.edu.xidian.repace.xml2hbase.filter.TestFilter.java

public void readFields(final DataInput in) throws IOException {
    this.columnFamily = Bytes.readByteArray(in);
    if (this.columnFamily.length == 0) {
        this.columnFamily = null;
    }//from w  w  w .j a v  a2  s  .  com
    this.columnQualifier = Bytes.readByteArray(in);
    if (this.columnQualifier.length == 0) {
        this.columnQualifier = null;
    }
    this.compareOp = CompareOp.valueOf(in.readUTF());
    this.comparator = (WritableByteArrayComparable) HbaseObjectWritable.readObject(in, null);
    this.foundColumn = in.readBoolean();
    this.matchedColumn = in.readBoolean();
    this.filterIfMissing = in.readBoolean();
    this.latestVersionOnly = in.readBoolean();
}

From source file:edu.umd.cloud9.collection.wikipedia.WikipediaPageOld.java

/**
 * Serializes this object./*from   w ww .  ja  v  a  2 s  . c  o  m*/
 */
public void readFields(DataInput in) throws IOException {
    int length = WritableUtils.readVInt(in);
    byte[] bytes = new byte[length];
    in.readFully(bytes, 0, length);
    WikipediaPageOld.readPage(this, new String(bytes, "UTF-8"));
    language = in.readUTF();
}

From source file:com.mobicage.rogerthat.registration.RegistrationWizard2.java

@SuppressWarnings("unchecked")
@Override/* w  w w.  ja v a2s  . com*/
public void readFromPickle(int version, DataInput in) throws IOException, PickleException {
    T.UI();
    super.readFromPickle(version, in);
    boolean set = in.readBoolean();
    if (set)
        mCredentials = new Credentials(new Pickle(in.readInt(), in));
    set = in.readBoolean();
    mEmail = set ? in.readUTF() : null;
    mTimestamp = in.readLong();
    mRegistrationId = in.readUTF();
    mInGoogleAuthenticationProcess = in.readBoolean();
    mInstallationId = in.readUTF();
    // A version bump was forgotten when serializing mDeviceId, so we need a try/catch
    try {
        mDeviceId = in.readUTF();
    } catch (EOFException e) {
        mDeviceId = null;
    }
    if (version >= 2) {
        try {
            set = in.readBoolean();
            mBeaconRegions = set
                    ? new GetBeaconRegionsResponseTO((Map<String, Object>) JSONValue.parse(in.readUTF()))
                    : null;

            set = in.readBoolean();
            if (set) {
                String detectedBeacons = in.readUTF();
                JSONArray db1 = (JSONArray) JSONValue.parse(detectedBeacons);
                if (db1 != null) {
                    mDetectedBeacons = new HashSet<String>();
                    for (int i = 0; i < db1.size(); i++) {
                        mDetectedBeacons.add((String) db1.get(i));
                    }
                } else {
                    mDetectedBeacons = null;
                }
            } else {
                mDetectedBeacons = null;
            }
        } catch (IncompleteMessageException e) {
            L.bug(e);
        }
    }
}