java.io.ObjectOutputStream Java Examples

The following examples show how to use java.io.ObjectOutputStream. 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: MemoryCheckpointStorageTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Test
public void testTaskOwnedStateStream() throws Exception {
	final List<String> state = Arrays.asList("Flopsy", "Mopsy", "Cotton Tail", "Peter");

	final MemoryBackendCheckpointStorage storage = new MemoryBackendCheckpointStorage(
			new JobID(), null, null, DEFAULT_MAX_STATE_SIZE);

	StreamStateHandle stateHandle;

	try (CheckpointStateOutputStream stream = storage.createTaskOwnedStateStream()) {
		assertTrue(stream instanceof MemoryCheckpointOutputStream);

		new ObjectOutputStream(stream).writeObject(state);
		stateHandle = stream.closeAndGetHandle();
	}

	try (ObjectInputStream in = new ObjectInputStream(stateHandle.openInputStream())) {
		assertEquals(state, in.readObject());
	}
}
 
Example #2
Source File: SerializationTest.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
public static void test(Object a) {
    try {
        File objectbin = new File("object.bin");
        FileOutputStream fos = new FileOutputStream(objectbin);
        ObjectOutputStream out = new ObjectOutputStream(fos);
        out.writeObject(a);
        fos.close();
        FileInputStream fis = new FileInputStream(objectbin);
        ObjectInputStream in = new ObjectInputStream(fis);
        Object o = in.readObject();
        fis.close();
        System.err.println(o);
    } catch (Throwable ex) {
        ex.printStackTrace();
        failed = true;
    }
}
 
Example #3
Source File: BloomFilterLanguageModel.java    From joshua with Apache License 2.0 6 votes vote down vote up
/**
 * Builds a language model and stores it in a file.
 * 
 * @param argv command-line arguments
 */
public static void main(String[] argv) {
  if (argv.length < 5) {
    String msg = "usage: BloomFilterLanguageModel <statistics file> <order> <size>"
        + " <quantization base> <output file>";
    System.err.println(msg);
    LOG.error(msg);
    return;
  }
  int order = Integer.parseInt(argv[1]);
  int size = (int) (Integer.parseInt(argv[2]) * Math.pow(2, 23));
  double base = Double.parseDouble(argv[3]);

  try {
    BloomFilterLanguageModel lm = new BloomFilterLanguageModel(argv[0], order, size, base);

    ObjectOutputStream out =
        new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(argv[4])));

    lm.writeExternal(out);
    out.close(); //TODO: try-with-resources
  } catch (IOException e) {
    LOG.error(e.getMessage(), e);
  }
}
 
Example #4
Source File: NumericValueExp.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serializes a {@link NumericValueExp} to an {@link ObjectOutputStream}.
 */
private void writeObject(ObjectOutputStream out)
        throws IOException {
  if (compat)
  {
    // Serializes this instance in the old serial form
    //
    ObjectOutputStream.PutField fields = out.putFields();
    fields.put("doubleVal", doubleValue());
    fields.put("longVal", longValue());
    fields.put("valIsLong", isLong());
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example #5
Source File: XYCoordinateTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    XYCoordinate v1 = new XYCoordinate(1.0, 2.0);
    XYCoordinate v2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(v1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        v2 = (XYCoordinate) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(v1, v2);
}
 
Example #6
Source File: EggTool.java    From frog with Apache License 2.0 6 votes vote down vote up
/**
 * Frogs which have higher energy lay eggs
 * 
 * 利用Java串行机制存盘。 能量多(也就是吃的更多)的Frog下蛋并存盘, 以进行下一轮测试,能量少的Frog被淘汰,没有下蛋的资格。
 * 用能量的多少来简化生存竟争模拟,每次下蛋数量固定为EGG_QTY个
 */
public static void layEggs() {
	sortFrogsOrderByEnergyDesc();

	Frog first = Env.frogs.get(0);
	Frog last = Env.frogs.get(Env.frogs.size() - 1);

	try {
		Env.eggs.clear();
		for (int i = 0; i < Env.EGG_QTY; i++)
			Env.eggs.add(new Egg(Env.frogs.get(i)));
		FileOutputStream fo = new FileOutputStream(Application.CLASSPATH + "eggs.ser");
		ObjectOutputStream so = new ObjectOutputStream(fo);
		so.writeObject(Env.eggs);
		so.close();
		System.out.print("\r1st frog has " + first.organs.size() + " organs, energy=" + first.energy  );
		System.out.println(", Last frog has " + last.organs.size() + " organs,  energy=" + last.energy);
		System.out.println("Saved "+Env.eggs.size() +" eggs to file '" + Application.CLASSPATH + "eggs.ser'");
	} catch (IOException e) {
		System.out.println(e);
	}
}
 
Example #7
Source File: ShortArrays.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Write and read short arrays to/from a stream.  The benchmark is run in
 * batches, with each batch consisting of a fixed number of read/write
 * cycles.  The ObjectOutputStream is reset after each batch of cycles has
 * completed.
 * Arguments: <array size> <# batches> <# cycles per batch>
 */
public long run(String[] args) throws Exception {
    int size = Integer.parseInt(args[0]);
    int nbatches = Integer.parseInt(args[1]);
    int ncycles = Integer.parseInt(args[2]);
    short[][] arrays = new short[ncycles][size];
    StreamBuffer sbuf = new StreamBuffer();
    ObjectOutputStream oout =
        new ObjectOutputStream(sbuf.getOutputStream());
    ObjectInputStream oin =
        new ObjectInputStream(sbuf.getInputStream());

    doReps(oout, oin, sbuf, arrays, 1);     // warmup

    long start = System.currentTimeMillis();
    doReps(oout, oin, sbuf, arrays, nbatches);
    return System.currentTimeMillis() - start;
}
 
Example #8
Source File: ModelMBeanInfoSupport.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serializes a {@link ModelMBeanInfoSupport} to an {@link ObjectOutputStream}.
 */
private void writeObject(ObjectOutputStream out)
throws IOException {
    if (compat) {
        // Serializes this instance in the old serial form
        //
        ObjectOutputStream.PutField fields = out.putFields();
        fields.put("modelMBeanDescriptor", modelMBeanDescriptor);
        fields.put("mmbAttributes", modelMBeanAttributes);
        fields.put("mmbConstructors", modelMBeanConstructors);
        fields.put("mmbNotifications", modelMBeanNotifications);
        fields.put("mmbOperations", modelMBeanOperations);
        fields.put("currClass", currClass);
        out.writeFields();
    } else {
        // Serializes this instance in the new serial form
        //
        out.defaultWriteObject();
    }
}
 
Example #9
Source File: ObjArrays.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Run benchmark for given number of batches, with given number of cycles
 * for each batch.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, Node[][] arrays, int nbatches)
    throws Exception
{
    int ncycles = arrays.length;
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        oout.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeObject(arrays[j]);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readObject();
        }
    }
}
 
Example #10
Source File: SymbolicXYItemLabelGeneratorTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator();
    SymbolicXYItemLabelGenerator g2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(g1);
        out.close();

        ObjectInput in = new ObjectInputStream(
            new ByteArrayInputStream(buffer.toByteArray())
        );
        g2 = (SymbolicXYItemLabelGenerator) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(g1, g2);
}
 
Example #11
Source File: Ints.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Write and read int values to/from a stream.  The benchmark is run in
 * batches: each "batch" consists of a fixed number of read/write cycles,
 * and the stream is flushed (and underlying stream buffer cleared) in
 * between each batch.
 * Arguments: <# batches> <# cycles per batch>
 */
public long run(String[] args) throws Exception {
    int nbatches = Integer.parseInt(args[0]);
    int ncycles = Integer.parseInt(args[1]);
    StreamBuffer sbuf = new StreamBuffer();
    ObjectOutputStream oout =
        new ObjectOutputStream(sbuf.getOutputStream());
    ObjectInputStream oin =
        new ObjectInputStream(sbuf.getInputStream());

    doReps(oout, oin, sbuf, 1, ncycles);    // warmup

    long start = System.currentTimeMillis();
    doReps(oout, oin, sbuf, nbatches, ncycles);
    return System.currentTimeMillis() - start;
}
 
Example #12
Source File: EventBufferDumpedCommand.java    From netbeans with Apache License 2.0 6 votes vote down vote up
void writeObject(ObjectOutputStream out) throws IOException {
    out.writeInt(bufSize);
    out.writeBoolean(buffer != null);
    if (buffer != null) {
        Deflater compressor = new Deflater();
        // for small buffers, the compressed size can be somewhat larger than the original  
        byte[] compressedBytes = new byte[bufSize + 32]; 
        int compressedSize;
        
        compressor.setInput(buffer,startPos,bufSize);
        compressor.finish();
        compressedSize = compressor.deflate(compressedBytes);
        out.writeInt(compressedSize);
        out.write(compressedBytes,0,compressedSize);
    } else {
        out.writeUTF(eventBufferFileName);
    }
}
 
Example #13
Source File: ModelMBeanOperationInfo.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serializes a {@link ModelMBeanOperationInfo} to an {@link ObjectOutputStream}.
 */
private void writeObject(ObjectOutputStream out)
        throws IOException {
  if (compat)
  {
    // Serializes this instance in the old serial form
    //
    ObjectOutputStream.PutField fields = out.putFields();
    fields.put("operationDescriptor", operationDescriptor);
    fields.put("currClass", currClass);
    out.writeFields();
  }
  else
  {
    // Serializes this instance in the new serial form
    //
    out.defaultWriteObject();
  }
}
 
Example #14
Source File: ArithmeticStateMachine.java    From ratis with Apache License 2.0 6 votes vote down vote up
@Override
public long takeSnapshot() {
  final Map<String, Double> copy;
  final TermIndex last;
  try(final AutoCloseableLock readLock = readLock()) {
    copy = new HashMap<>(variables);
    last = getLastAppliedTermIndex();
  }

  final File snapshotFile =  storage.getSnapshotFile(last.getTerm(), last.getIndex());
  LOG.info("Taking a snapshot to file {}", snapshotFile);

  try(final ObjectOutputStream out = new ObjectOutputStream(
      new BufferedOutputStream(new FileOutputStream(snapshotFile)))) {
    out.writeObject(copy);
  } catch(IOException ioe) {
    LOG.warn("Failed to write snapshot file \"" + snapshotFile
        + "\", last applied index=" + last);
  }

  return last.getIndex();
}
 
Example #15
Source File: DateFormatSymbolsTest.java    From j2objc with Apache License 2.0 6 votes vote down vote up
public void test_serialization() throws Exception {
    DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRANCE);
    String[][] zoneStrings = symbols.getZoneStrings();
    assertNotNull(zoneStrings);

    // serialize
    ByteArrayOutputStream byteOStream = new ByteArrayOutputStream();
    ObjectOutputStream objectOStream = new ObjectOutputStream(byteOStream);
    objectOStream.writeObject(symbols);

    // and deserialize
    ObjectInputStream objectIStream = new ObjectInputStream(
            new ByteArrayInputStream(byteOStream.toByteArray()));
    DateFormatSymbols symbolsD = (DateFormatSymbols) objectIStream
            .readObject();

    String[][] zoneStringsD = symbolsD.getZoneStrings();
    assertNotNull(zoneStringsD);
    assertEquals(symbols, symbolsD);
}
 
Example #16
Source File: SmallObjTrees.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Run benchmark for given number of batches, with each batch containing the
 * given number of cycles.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, Node[] trees, int nbatches)
    throws Exception
{
    int ncycles = trees.length;
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        oout.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeObject(trees[j]);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readObject();
        }
    }
}
 
Example #17
Source File: DocumentImpl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @serialData Serialized fields. Convert Maps to Hashtables and Lists
 * to Vectors for backward compatibility.
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    // Convert Maps to Hashtables, Lists to Vectors
    Vector<NodeIterator> it = (iterators == null)? null : new Vector<>(iterators);
    Vector<Range> r = (ranges == null)? null : new Vector<>(ranges);

    Hashtable<NodeImpl, Vector<LEntry>> el = null;
    if (eventListeners != null) {
        el = new Hashtable<>();
        for (Map.Entry<NodeImpl, List<LEntry>> e : eventListeners.entrySet()) {
             el.put(e.getKey(), new Vector<>(e.getValue()));
        }
    }

    // Write serialized fields
    ObjectOutputStream.PutField pf = out.putFields();
    pf.put("iterators", it);
    pf.put("ranges", r);
    pf.put("eventListeners", el);
    pf.put("mutationEvents", mutationEvents);
    out.writeFields();
}
 
Example #18
Source File: MeanAndStandardDeviationTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    MeanAndStandardDeviation m1 = new MeanAndStandardDeviation(1.2, 3.4);
    MeanAndStandardDeviation m2 = null;

    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(m1);
        out.close();

        ObjectInput in = new ObjectInputStream(
            new ByteArrayInputStream(buffer.toByteArray())
        );
        m2 = (MeanAndStandardDeviation) in.readObject();
        in.close();
    }
    catch (Exception e) {
        System.out.println(e.toString());
    }
    assertEquals(m1, m2);

}
 
Example #19
Source File: StrokeMapTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * A check for serialization.
 */
public void testSerialization2() {
    StrokeMap m1 = new StrokeMap();
    m1.put("K1", new BasicStroke(1.1f));
    m1.put("K2", new BasicStroke(2.2f));
    StrokeMap m2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(m1);
        out.close();

        ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(
                buffer.toByteArray()));
        m2 = (StrokeMap) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(m1, m2);
}
 
Example #20
Source File: StackedXYAreaRendererTests.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Serialize an instance, restore it, and check for equality.
 */
public void testSerialization() {
    StackedXYAreaRenderer r1 = new StackedXYAreaRenderer();
    r1.setShapePaint(Color.red);
    r1.setShapeStroke(new BasicStroke(1.23f));
    StackedXYAreaRenderer r2 = null;
    try {
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        ObjectOutput out = new ObjectOutputStream(buffer);
        out.writeObject(r1);
        out.close();

        ObjectInput in = new ObjectInputStream(
                new ByteArrayInputStream(buffer.toByteArray()));
        r2 = (StackedXYAreaRenderer) in.readObject();
        in.close();
    }
    catch (Exception e) {
        e.printStackTrace();
    }
    assertEquals(r1, r2);
}
 
Example #21
Source File: FileTrans.java    From ThriftBook with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) 
        throws IOException, TTransportException, ClassNotFoundException {
    Trade trade = new Trade();
    trade.symbol = "F";
    trade.price = 13.10;
    trade.size = 2500;

    TSimpleFileTransport trans_out = new TSimpleFileTransport("data",false,true);	
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(trade);
    trans_out.write(baos.toByteArray());				
    trans_out.close();				

    TSimpleFileTransport trans_in = new TSimpleFileTransport("data",true,false);
    byte[] buf = new byte[128];
    int iBytesRead = trans_in.read(buf, 0, buf.length);		
    ByteArrayInputStream bais = new ByteArrayInputStream(buf);
    ObjectInputStream ois = new ObjectInputStream(bais);
    trade = (Trade) ois.readObject();

    System.out.println("Trade(" + iBytesRead + "): " + trade.symbol
            + " " + trade.size + " @ " + trade.price);
}
 
Example #22
Source File: FloatArrays.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Run benchmark for given number of batches, with given number of cycles
 * for each batch.
 */
void doReps(ObjectOutputStream oout, ObjectInputStream oin,
            StreamBuffer sbuf, float[][] arrays, int nbatches)
    throws Exception
{
    int ncycles = arrays.length;
    for (int i = 0; i < nbatches; i++) {
        sbuf.reset();
        oout.reset();
        for (int j = 0; j < ncycles; j++) {
            oout.writeObject(arrays[j]);
        }
        oout.flush();
        for (int j = 0; j < ncycles; j++) {
            oin.readObject();
        }
    }
}
 
Example #23
Source File: Permissions.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @serialData Default fields.
 */
/*
 * Writes the contents of the permsMap field out as a Hashtable for
 * serialization compatibility with earlier releases.
 */
private void writeObject(ObjectOutputStream out) throws IOException {
    // Don't call out.defaultWriteObject()

    // Copy perms into a Hashtable
    Hashtable<Permission, Permission> perms =
            new Hashtable<>(permsMap.size()*2);
    synchronized (this) {
        perms.putAll(permsMap);
    }

    // Write out serializable fields
    ObjectOutputStream.PutField pfields = out.putFields();
    pfields.put("perms", perms);
    out.writeFields();
}
 
Example #24
Source File: EdgeQueryLogic.java    From datawave with Apache License 2.0 6 votes vote down vote up
protected String serializePrefilter() {
    
    String retVal = null;
    if (prefilterValues != null) {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            ObjectOutputStream oos = new ObjectOutputStream(baos);
            oos.writeObject(prefilterValues);
            oos.close();
        } catch (IOException ex) {
            log.error("Some error encoding the prefilters...", ex);
        }
        retVal = new String(Base64.encodeBase64(baos.toByteArray()));
    }
    
    return retVal;
}
 
Example #25
Source File: ClassDesc.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Write and read class descriptors to/from a stream.
 * Arguments: <# cycles>
 */
public long run(String[] args) throws Exception {
    int ncycles = Integer.parseInt(args[0]);
    StreamBuffer sbuf = new StreamBuffer();
    ObjectOutputStream oout =
        new ObjectOutputStream(sbuf.getOutputStream());
    ObjectInputStream oin =
        new ObjectInputStream(sbuf.getInputStream());
    ObjectStreamClass desc = ObjectStreamClass.lookup(Dummy50.class);

    doReps(oout, oin, sbuf, desc, 1);       // warmup

    long start = System.currentTimeMillis();
    doReps(oout, oin, sbuf, desc, ncycles);
    return System.currentTimeMillis() - start;
}
 
Example #26
Source File: JCheckBoxMenuItem.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * See readObject() and writeObject() in JComponent for more
 * information about serialization in Swing.
 */
private void writeObject(ObjectOutputStream s) throws IOException {
    s.defaultWriteObject();
    if (getUIClassID().equals(uiClassID)) {
        byte count = JComponent.getWriteObjCounter(this);
        JComponent.setWriteObjCounter(this, --count);
        if (count == 0 && ui != null) {
            ui.installUI(this);
        }
    }
}
 
Example #27
Source File: MOFilterTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Write objects and return a byte array with the bytes.
 *
 * @param objects zero or more objects to serialize
 * @return the byte array of the serialized objects
 * @throws IOException if an exception occurs
 */
static byte[] writeObjects(Object... objects)  throws IOException {
    byte[] bytes;
    try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
         ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        for (Object o : objects) {
            oos.writeObject(o);
        }
        bytes = baos.toByteArray();
    }
    return bytes;
}
 
Example #28
Source File: ShortArrayTest.java    From rtg-tools with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void testSerial() throws IOException {
  final ShortArray la = new ShortArray(10);
  for (int i = 0; i < 10; ++i) {
    la.set(i, i * 4 + 7);
  }
  final ByteArrayOutputStream out =  new ByteArrayOutputStream();
  la.save(new ObjectOutputStream(out));
  final ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
  final ShortIndex index2 = ShortCreate.loadIndex(new ObjectInputStream(in));
  assertTrue(index2 instanceof ShortArray);
  assertEquals(la.length(), index2.length());
  for (int i = 0; i < 10; ++i) {
    assertEquals(la.get(i), index2.get(i));
  }
}
 
Example #29
Source File: ImmutableDescriptorSerialTest.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
private static <T> T serialize(T x) throws Exception {
    ByteArrayOutputStream bout = new ByteArrayOutputStream();
    ObjectOutputStream oout = new ObjectOutputStream(bout);
    oout.writeObject(x);
    oout.close();
    byte[] bytes = bout.toByteArray();
    ByteArrayInputStream bin = new ByteArrayInputStream(bytes);
    ObjectInputStream oin = new ObjectInputStream(bin);
    return (T) oin.readObject();
}
 
Example #30
Source File: CommonWebRowSetTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
protected ByteArrayOutputStream writeWebRowSetWithOutputStream(WebRowSet rs) throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    try (ObjectOutputStream oos = new ObjectOutputStream(baos)) {
        rs.writeXml(oos);
    }
    return baos;
}