Java Code Examples for java.io.ObjectOutputStream#writeShort()
The following examples show how to use
java.io.ObjectOutputStream#writeShort() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Shorts.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
/** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, StreamBuffer sbuf, int nbatches, int ncycles) throws Exception { for (int i = 0; i < nbatches; i++) { sbuf.reset(); for (int j = 0; j < ncycles; j++) { oout.writeShort(0); } oout.flush(); for (int j = 0; j < ncycles; j++) { oin.readShort(); } } }
Example 2
Source File: Shorts.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, StreamBuffer sbuf, int nbatches, int ncycles) throws Exception { for (int i = 0; i < nbatches; i++) { sbuf.reset(); for (int j = 0; j < ncycles; j++) { oout.writeShort(0); } oout.flush(); for (int j = 0; j < ncycles; j++) { oin.readShort(); } } }
Example 3
Source File: MemberBox.java From openbd-core with GNU General Public License v3.0 | 6 votes |
/** * Writes an array of parameter types to the stream. * * Requires special handling because primitive types cannot be * found upon deserialization by the default Java implementation. */ private static void writeParameters(ObjectOutputStream out, Class<?>[] parms) throws IOException { out.writeShort(parms.length); outer: for (int i=0; i < parms.length; i++) { Class<?> parm = parms[i]; boolean primitive = parm.isPrimitive(); out.writeBoolean(primitive); if (!primitive) { out.writeObject(parm); continue; } for (int j=0; j < primitives.length; j++) { if (parm.equals(primitives[j])) { out.writeByte(j); continue outer; } } throw new IllegalArgumentException("Primitive " + parm + " not found"); } }
Example 4
Source File: Shorts.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, StreamBuffer sbuf, int nbatches, int ncycles) throws Exception { for (int i = 0; i < nbatches; i++) { sbuf.reset(); for (int j = 0; j < ncycles; j++) { oout.writeShort(0); } oout.flush(); for (int j = 0; j < ncycles; j++) { oin.readShort(); } } }
Example 5
Source File: Shorts.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, StreamBuffer sbuf, int nbatches, int ncycles) throws Exception { for (int i = 0; i < nbatches; i++) { sbuf.reset(); for (int j = 0; j < ncycles; j++) { oout.writeShort(0); } oout.flush(); for (int j = 0; j < ncycles; j++) { oin.readShort(); } } }
Example 6
Source File: Shorts.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Run benchmark for given number of batches, with given number of cycles * for each batch. */ void doReps(ObjectOutputStream oout, ObjectInputStream oin, StreamBuffer sbuf, int nbatches, int ncycles) throws Exception { for (int i = 0; i < nbatches; i++) { sbuf.reset(); for (int j = 0; j < ncycles; j++) { oout.writeShort(0); } oout.flush(); for (int j = 0; j < ncycles; j++) { oin.readShort(); } } }
Example 7
Source File: RuntimeColorMap.java From tcl-regex-java with Apache License 2.0 | 5 votes |
private void writeObject(ObjectOutputStream stream) throws IOException { // TreeRangeMap is not Serializable. Set<Map.Entry<Range<Integer>, Short>> entries = fullMap.asMapOfRanges().entrySet(); stream.writeInt(entries.size()); for (Map.Entry<Range<Integer>, Short> me : entries) { stream.writeObject(me.getKey()); stream.writeShort(me.getValue()); } }
Example 8
Source File: CustomObjTrees.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeBoolean(z); out.writeByte(b); out.writeChar(c); out.writeShort(s); out.writeInt(i); out.writeFloat(f); out.writeLong(j); out.writeDouble(d); out.writeObject(str); out.writeObject(parent); out.writeObject(left); out.writeObject(right); }
Example 9
Source File: DenseArrayOfZonedDateTimes.java From morpheus-core with Apache License 2.0 | 5 votes |
@Override public final void write(ObjectOutputStream os, int[] indexes) throws IOException { for (int index : indexes) { final long value = values[index]; os.writeLong(value); if (value != defaultValueAsLong) { os.writeShort(zoneIds[index]); } } }
Example 10
Source File: MappedArrayOfZonedDateTimes.java From morpheus-core with Apache License 2.0 | 5 votes |
/** Custom serialization */ private void writeObject(ObjectOutputStream os) throws IOException { os.writeInt(length); os.writeLong(defaultValueAsLong); os.writeShort(defaultZoneId); os.writeObject(defaultValue); for (int i=0; i<length; ++i) { final int byteIndex = i * BYTE_COUNT; final long epochMillis = byteBuffer.getLong(byteIndex); final short zoneId = byteBuffer.getShort(byteIndex + 8); os.writeLong(epochMillis); os.writeShort(zoneId); } }
Example 11
Source File: MappedArrayOfZonedDateTimes.java From morpheus-core with Apache License 2.0 | 5 votes |
@Override public final void write(ObjectOutputStream os, int[] indexes) throws IOException { for (int index : indexes) { final int byteIndex = index * BYTE_COUNT; final long epochMillis = byteBuffer.getLong(byteIndex); final short zoneId = byteBuffer.getShort(byteIndex + 8); os.writeLong(epochMillis); os.writeShort(zoneId); } }
Example 12
Source File: SparseArrayOfZonedDateTimes.java From morpheus-core with Apache License 2.0 | 5 votes |
@Override public final void write(ObjectOutputStream os, int[] indexes) throws IOException { for (int index : indexes) { final long value = getLong(index); os.writeLong(value); if (value != defaultValueAsLong) { final short zoneId = zoneIds.get(index); os.writeShort(zoneId); } } }
Example 13
Source File: CustomObjTrees.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeBoolean(z); out.writeByte(b); out.writeChar(c); out.writeShort(s); out.writeInt(i); out.writeFloat(f); out.writeLong(j); out.writeDouble(d); out.writeObject(str); out.writeObject(parent); out.writeObject(left); out.writeObject(right); }
Example 14
Source File: CustomObjTrees.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeBoolean(z); out.writeByte(b); out.writeChar(c); out.writeShort(s); out.writeInt(i); out.writeFloat(f); out.writeLong(j); out.writeDouble(d); out.writeObject(str); out.writeObject(parent); out.writeObject(left); out.writeObject(right); }
Example 15
Source File: CustomObjTrees.java From hottub with GNU General Public License v2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeBoolean(z); out.writeByte(b); out.writeChar(c); out.writeShort(s); out.writeInt(i); out.writeFloat(f); out.writeLong(j); out.writeDouble(d); out.writeObject(str); out.writeObject(parent); out.writeObject(left); out.writeObject(right); }
Example 16
Source File: CustomObjTrees.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeBoolean(z); out.writeByte(b); out.writeChar(c); out.writeShort(s); out.writeInt(i); out.writeFloat(f); out.writeLong(j); out.writeDouble(d); out.writeObject(str); out.writeObject(parent); out.writeObject(left); out.writeObject(right); }
Example 17
Source File: IamSession.java From super-cloudops with Apache License 2.0 | 5 votes |
/** * Serializes this object to the specified output stream for JDK * Serialization. * * @param out * output stream used for Object serialization. * @throws IOException * if any of this object's fields cannot be written to the * stream. * @since 1.0 */ @JsonIgnore private void writeObject(ObjectOutputStream out) throws IOException { out.defaultWriteObject(); short alteredFieldsBitMask = getAlteredFieldsBitMask(); out.writeShort(alteredFieldsBitMask); if (id != null) { out.writeObject(id); } if (startTimestamp != null) { out.writeObject(startTimestamp); } if (stopTimestamp != null) { out.writeObject(stopTimestamp); } if (lastAccessTime != null) { out.writeObject(lastAccessTime); } if (timeout != 0l) { out.writeLong(timeout); } if (expired) { out.writeBoolean(expired); } if (host != null) { out.writeUTF(host); } if (!CollectionUtils.isEmpty(attributes)) { out.writeObject(attributes); } }
Example 18
Source File: StarRater.java From mars-sim with GNU General Public License v3.0 | 5 votes |
/** * Converts an image to a compressed byte array. GZIPs the image to reduce the size. Use compressedByteArrayToImage(byte[] data) to * retrieve the original image. The image is not recognizable as image from standard tools. * * @param image The image to convert. * @return The byte array. * @throws IOException if something goes wrong. */ public byte[] imageToCompressedByteArray(Image image) throws IOException { // get image size int width = image.getWidth(null); int height = image.getHeight(null); // store image data as raw int values try { int[] imageSource = new int[width * height]; PixelGrabber pg = new PixelGrabber(image, 0, 0, width, height, imageSource, 0, width); pg.grabPixels(); // zip data ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); GZIPOutputStream zippedStream = new GZIPOutputStream(byteStream); ObjectOutputStream objectStream = new ObjectOutputStream(zippedStream); objectStream.writeShort(width); objectStream.writeShort(height); objectStream.writeObject(imageSource); objectStream.flush(); objectStream.close(); return byteStream.toByteArray(); } catch (Exception e) { throw new IOException("Error storing image in object: " + e); } }
Example 19
Source File: RasterTileResizeHelper.java From geowave with Apache License 2.0 | 5 votes |
private void writeObject(final ObjectOutputStream aOutputStream) throws IOException { final byte[] adapterBytes = PersistenceUtils.toBinary(newAdapter); final byte[] indexBytes = PersistenceUtils.toBinary(index); aOutputStream.writeShort(adapterBytes.length); aOutputStream.write(adapterBytes); aOutputStream.writeShort(indexBytes.length); aOutputStream.write(indexBytes); aOutputStream.writeShort(oldAdapterId); aOutputStream.writeShort(newAdapterId); aOutputStream.flush(); }
Example 20
Source File: CustomObjTrees.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private void writeObject(ObjectOutputStream out) throws IOException { out.writeBoolean(z); out.writeByte(b); out.writeChar(c); out.writeShort(s); out.writeInt(i); out.writeFloat(f); out.writeLong(j); out.writeDouble(d); out.writeObject(str); out.writeObject(parent); out.writeObject(left); out.writeObject(right); }