List of usage examples for org.apache.hadoop.io ShortWritable readFields
@Override public void readFields(DataInput in) throws IOException
From source file:org.shaf.core.util.IOUtilsTest.java
License:Apache License
/** * Test writing of {@code short} value.// w w w. ja v a2 s . com */ @Test public void testWriteShort() { byte[] buf = null; short value = 123; try (ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream out = new DataOutputStream(baos);) { IOUtils.writeObject(value, out); buf = baos.toByteArray(); } catch (IOException exc) { fail(exc.getMessage()); } try (ByteArrayInputStream bais = new ByteArrayInputStream(buf); DataInputStream in = new DataInputStream(bais);) { ShortWritable probe = new ShortWritable(); probe.readFields(in); assertEquals(value, probe.get()); } catch (IOException exc) { fail(exc.getMessage()); } }