/** {@inheritDoc} */ public void writeObjectUnshared(final Object obj) throws IOException { oos.writeUnshared(obj); }
writeUnshared(objField); } else { writeObject(objField);
@Override public boolean put(final T item) throws IOException { output.writeUnshared(item); return true; }
/** {@inheritDoc} */ public void writeObjectUnshared(final Object obj) throws IOException { oos.writeUnshared(obj); }
/** {@inheritDoc} */ public void writeObjectUnshared(final Object obj) throws IOException { oos.writeUnshared(obj); }
/** {@inheritDoc} */ public void writeObjectUnshared(final Object obj) throws IOException { oos.writeUnshared(obj); }
/** {@inheritDoc} */ public void writeObjectUnshared(final Object obj) throws IOException { oos.writeUnshared(obj); }
/** {@inheritDoc} */ public void writeObjectUnshared(final Object obj) throws IOException { oos.writeUnshared(obj); }
@Override public void writeUnshared(Object obj) throws IOException { super.writeUnshared(obj); super.flush(); }
/** Serializes o to bytes. */ @Override public void toStream(T o, OutputStream bytes) throws IOException { ObjectOutputStream out = new ObjectOutputStream(bytes); out.writeUnshared(o); out.close(); } }
@Override public int put(final List<T> buffer, final int from, final int to) throws IOException { output.writeUnshared( buffer .subList(from, to) .toArray(new Object[to - from]) ); return to - from; }
private void write(OutputStream out, Object obj) throws IOException { ObjectOutputStream objectOutputStream = new ObjectOutputStream(out); if (shared) { objectOutputStream.writeObject(obj); } else { objectOutputStream.writeUnshared(obj); } // Force flush if not yet written due to internal behavior if pos < 1024 objectOutputStream.flush(); }
private void write(OutputStream out, Object obj) throws IOException { ObjectOutputStream objectOutputStream = new ObjectOutputStream(out); if (shared) { objectOutputStream.writeObject(obj); } else { objectOutputStream.writeUnshared(obj); } // Force flush if not yet written due to internal behavior if pos < 1024 objectOutputStream.flush(); }
/** * We do this ourself. * * @param stream * @throws IOException */ private void writeObject(java.io.ObjectOutputStream stream) throws IOException { stream.writeShort(this.version); stream.writeLong(this.date); stream.writeLong(this.threadID); stream.writeUnshared(this.stackTrace); stream.writeUnshared(this.channel); stream.writeUnshared(this.value); stream.writeUnshared(this.additionalInfo); }
ByteArrayOutputStream baos = new ByteArrayOutputStream(); ObjectOutputStream oos = new ObjectOutputStream(baos); List<String> strings = new ArrayList<String>(); strings.add("hello"); oos.writeUnshared(strings); strings.set(0, "world"); oos.writeUnshared(strings); oos.close(); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); System.out.println(ois.readObject()); System.out.println(ois.readObject());
public static void writeToStream(ObjectOutputStream stream, StreamSampleRow row, Set<Object> backrefs) throws IOException { stream.writeUnshared(row); for(Map.Entry<Object, Object> e: row.data.entrySet()) { backrefs.add(e.getKey()); Object v = e.getValue(); if (v != null && !PRIMITIVES.contains(v.getClass())) { backrefs.add(v); } if (row.sharedStrings && v instanceof String) { backrefs.add(v); } } }
protected byte[] serializeJava( Object object ) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); try( ObjectOutputStream out = new ObjectOutputStream( bout ) ) { out.writeUnshared( object ); out.flush(); return bout.toByteArray(); } catch( IOException ex ) { throw new SerializationException( "Unable to serialize using Java serialization", ex ); } }
protected byte[] serializeJava( Object object ) { ByteArrayOutputStream bout = new ByteArrayOutputStream(); try( ObjectOutputStream out = new ObjectOutputStream( bout ) ) { out.writeUnshared( object ); out.flush(); return bout.toByteArray(); } catch( IOException ex ) { throw new SerializationException( "Unable to serialize using Java serialization", ex ); } }
/** * Writes the given object to the given output stream. The default * implementation uses {@link java.io.ObjectOutputStream#writeUnshared} as * well as periodically calls {@link java.io.ObjectOutputStream#reset} on * the output stream. Subclasses may choose to change this behavior by * overriding this method. * * @param ostream the output stream to which the object should be written * @param obj the object to write */ protected void serializeObject(ObjectOutputStream ostream, Object obj) throws IOException { ostream.writeUnshared(obj); _numObjectsWrittenSinceLastReset++; if(_numObjectsWrittenSinceLastReset >= _resetNumObjects) { ostream.reset(); _numObjectsWrittenSinceLastReset = 0; } }
private void serializeMessageToBuffer(@NonNull HtspMessage message) { mLock.lock(); try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ObjectOutputStream objectOutput = new ObjectOutputStream(outputStream); objectOutput.writeUnshared(message); objectOutput.flush(); mBuffer.position(mBuffer.limit()); mBuffer.limit(mBuffer.capacity()); mBuffer.put(outputStream.toByteArray()); mBuffer.flip(); } catch (IOException e) { // Ignore? Timber.w("Caught IOException, ignoring (" + mDataSourceNumber + ")", e); } catch (BufferOverflowException boe) { Timber.w("Caught BufferOverflowException, ignoring (" + mDataSourceNumber + ")", boe); } finally { mLock.unlock(); // Ignore } } }