List of usage examples for java.io ObjectInput readObject
public Object readObject() throws ClassNotFoundException, IOException;
From source file:com.conwet.silbops.model.AbstractMappingTest.java
@Test public void shouldExternalize() throws IOException, ClassNotFoundException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutput output = new ObjectOutputStream(baos); output.writeObject(instance);//from w ww. ja va 2 s . c o m output.close(); ObjectInput input = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); T decoded = instance.getThisType().cast(input.readObject()); assertThat(decoded).isEqualTo(instance); }
From source file:com.splicemachine.derby.stream.output.update.UpdateTableWriterBuilder.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { if (in.readBoolean()) operationContext = (OperationContext) in.readObject(); heapConglom = in.readLong();//from w ww .j ava 2 s . co m formatIds = ArrayUtil.readIntArray(in); columnOrdering = ArrayUtil.readIntArray(in); if (columnOrdering == null) columnOrdering = new int[] {}; pkCols = ArrayUtil.readIntArray(in); if (pkCols == null) pkCols = new int[0]; pkColumns = (FormatableBitSet) in.readObject(); heapList = (FormatableBitSet) in.readObject(); tableVersion = in.readUTF(); txn = SIDriver.driver().getOperationFactory().readTxn(in); execRowTypeFormatIds = ArrayUtil.readIntArray(in); execRowDefinition = WriteReadUtils.getExecRowFromTypeFormatIds(execRowTypeFormatIds); }
From source file:com.splicemachine.derby.stream.output.delete.DeleteTableWriterBuilder.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { heapConglom = in.readLong();/* ww w .ja v a 2 s . c o m*/ txn = SIDriver.driver().getOperationFactory().readTxn(in); if (in.readBoolean()) operationContext = (OperationContext) in.readObject(); }
From source file:org.jfree.data.xy.junit.XYIntervalSeriesCollectionTest.java
/** * Serialize an instance, restore it, and check for equality. *///from w ww. j av a 2 s . c o m public void testSerialization() { XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection(); XYIntervalSeries s1 = new XYIntervalSeries("Series"); s1.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5); XYIntervalSeriesCollection c2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(c1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); c2 = (XYIntervalSeriesCollection) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(c1, c2); // check independence c1.addSeries(new XYIntervalSeries("Empty")); assertFalse(c1.equals(c2)); c2.addSeries(new XYIntervalSeries("Empty")); assertTrue(c1.equals(c2)); }
From source file:com.near.chimerarevo.services.NewsService.java
private boolean readOfflineFile(String result) { try {/* w w w. j av a2s.c om*/ if (new File(getCacheDir() + "/posts.ser").exists()) { InputStream file = new FileInputStream(getCacheDir() + "/posts.ser"); ObjectInput input = new ObjectInputStream(new BufferedInputStream(file)); ArrayList<String> mJson = ((PostsListObject) input.readObject()).getJSONs(); input.close(); if (mJson != null && mJson.size() > 0) { try { JsonParser parser = new JsonParser(); JsonElement o1 = parser.parse(result); JsonElement o2 = parser.parse(mJson.get(0)); return !o1.equals(o2); } catch (Exception e) { e.printStackTrace(); } } } } catch (IOException | ClassNotFoundException | ClassCastException e) { e.printStackTrace(); } return false; }
From source file:com.ibm.sbt.services.client.base.datahandlers.EntityList.java
@Override public void readExternal(ObjectInput inputStream) throws IOException, ClassNotFoundException { // Retrieve the entity data and other values like endpoint name and service name Response data = (Response) inputStream.readObject(); List<Entity> entities = (List<Entity>) inputStream.readObject(); BaseService service = (BaseService) inputStream.readObject(); this.requestData = data; this.entities = entities; this.service = service; }
From source file:org.jfree.data.category.junit.CategoryToPieDatasetTest.java
/** * Serialize an instance, restore it, and check for equality. *///from ww w . jav a 2s.c om public void testSerialization() { DefaultCategoryDataset underlying = new DefaultCategoryDataset(); underlying.addValue(1.1, "R1", "C1"); underlying.addValue(2.2, "R1", "C2"); CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, TableOrder.BY_COLUMN, 1); CategoryToPieDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); d2 = (CategoryToPieDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); // regular equality for the datasets doesn't check the fields, just // the data values...so let's check some more things... assertEquals(d1.getUnderlyingDataset(), d2.getUnderlyingDataset()); assertEquals(d1.getExtractType(), d2.getExtractType()); assertEquals(d1.getExtractIndex(), d2.getExtractIndex()); }
From source file:org.jfree.data.xy.junit.CategoryTableXYDatasetTest.java
/** * Serialize an instance, restore it, and check for equality. *///from www . j av a2s . c om public void testSerialization() { CategoryTableXYDataset d1 = new CategoryTableXYDataset(); d1.add(1.0, 1.1, "Series 1"); d1.add(2.0, 2.2, "Series 1"); CategoryTableXYDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); d2 = (CategoryTableXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); }
From source file:de.pro.dbw.file.reflection.api.ReflectionCommentModel.java
@Override public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException { this.setId(in.readLong()); this.setGenerationTime(in.readLong()); this.setText(String.valueOf(in.readObject())); }
From source file:org.jfree.data.xy.junit.DefaultTableXYDatasetTest.java
/** * Serialize an instance, restore it, and check for equality. *//*www.j a va 2 s.co m*/ public void testSerialization() { DefaultTableXYDataset d1 = new DefaultTableXYDataset(); XYSeries s1 = new XYSeries("Series 1", true, false); s1.add(1.0, 1.1); s1.add(2.0, 2.2); d1.addSeries(s1); DefaultTableXYDataset d2 = null; try { ByteArrayOutputStream buffer = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(buffer); out.writeObject(d1); out.close(); ObjectInput in = new ObjectInputStream(new ByteArrayInputStream(buffer.toByteArray())); d2 = (DefaultTableXYDataset) in.readObject(); in.close(); } catch (Exception e) { e.printStackTrace(); } assertEquals(d1, d2); }