Search in sources :

Example 86 with ObjectOutputStream

use of java.io.ObjectOutputStream in project javatari by ppeccin.

the class RemoteTransmitter method connect.

private void connect(Socket toSocket) throws IOException {
    socket = toSocket;
    socket.setTcpNoDelay(true);
    socketOutputStream = socket.getOutputStream();
    outputStream = new ObjectOutputStream(socketOutputStream);
    socketInputStream = socket.getInputStream();
    inputStream = new ObjectInputStream(socketInputStream);
    resetUpdatesPending();
    console.clientConnected();
    notifyConnectionStatusListeners();
}
Also used : ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream)

Example 87 with ObjectOutputStream

use of java.io.ObjectOutputStream in project sessdb by ppdai.

the class AbstractSortedMapTable method persistBloomFilter.

public void persistBloomFilter() throws IOException {
    ensureNotClosed();
    File file = new File(this.bloomFilterFile);
    if (!file.exists()) {
        file.createNewFile();
    }
    FileOutputStream fos = null;
    ObjectOutputStream oos = null;
    try {
        fos = new FileOutputStream(file);
        oos = new ObjectOutputStream(fos);
        oos.writeObject(this.bloomFilter);
        oos.flush();
    } finally {
        oos.close();
        fos.close();
    }
}
Also used : FileOutputStream(java.io.FileOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) File(java.io.File)

Example 88 with ObjectOutputStream

use of java.io.ObjectOutputStream in project camel by apache.

the class JdbcCamelCodec method encode.

private byte[] encode(Object object) throws IOException {
    ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
    ObjectOutputStream objectOut = new ObjectOutputStream(bytesOut);
    objectOut.writeObject(object);
    objectOut.close();
    byte[] data = bytesOut.toByteArray();
    return data;
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream)

Example 89 with ObjectOutputStream

use of java.io.ObjectOutputStream in project flink by apache.

the class JavaSerializer method write.

@SuppressWarnings("unchecked")
@Override
public void write(Kryo kryo, Output output, T o) {
    try {
        ObjectMap graphContext = kryo.getGraphContext();
        ObjectOutputStream objectStream = (ObjectOutputStream) graphContext.get(this);
        if (objectStream == null) {
            objectStream = new ObjectOutputStream(output);
            graphContext.put(this, objectStream);
        }
        objectStream.writeObject(o);
        objectStream.flush();
    } catch (Exception ex) {
        throw new KryoException("Error during Java serialization.", ex);
    }
}
Also used : KryoException(com.esotericsoftware.kryo.KryoException) ObjectMap(com.esotericsoftware.kryo.util.ObjectMap) ObjectOutputStream(java.io.ObjectOutputStream) KryoException(com.esotericsoftware.kryo.KryoException)

Example 90 with ObjectOutputStream

use of java.io.ObjectOutputStream in project flink by apache.

the class DelimitedInputFormatTest method testSerialization.

@Test
public void testSerialization() throws Exception {
    final byte[] DELIMITER = new byte[] { 1, 2, 3, 4 };
    final int NUM_LINE_SAMPLES = 7;
    final int LINE_LENGTH_LIMIT = 12345;
    final int BUFFER_SIZE = 178;
    DelimitedInputFormat<String> format = new MyTextInputFormat();
    format.setDelimiter(DELIMITER);
    format.setNumLineSamples(NUM_LINE_SAMPLES);
    format.setLineLengthLimit(LINE_LENGTH_LIMIT);
    format.setBufferSize(BUFFER_SIZE);
    ByteArrayOutputStream baos = new ByteArrayOutputStream(4096);
    ObjectOutputStream oos = new ObjectOutputStream(baos);
    oos.writeObject(format);
    oos.flush();
    oos.close();
    ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
    @SuppressWarnings("unchecked") DelimitedInputFormat<String> deserialized = (DelimitedInputFormat<String>) ois.readObject();
    assertEquals(NUM_LINE_SAMPLES, deserialized.getNumLineSamples());
    assertEquals(LINE_LENGTH_LIMIT, deserialized.getLineLengthLimit());
    assertEquals(BUFFER_SIZE, deserialized.getBufferSize());
    assertArrayEquals(DELIMITER, deserialized.getDelimiter());
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) ObjectOutputStream(java.io.ObjectOutputStream) ObjectInputStream(java.io.ObjectInputStream) Test(org.junit.Test)

Aggregations

ObjectOutputStream (java.io.ObjectOutputStream)1102 ByteArrayOutputStream (java.io.ByteArrayOutputStream)760 ObjectInputStream (java.io.ObjectInputStream)428 ByteArrayInputStream (java.io.ByteArrayInputStream)375 IOException (java.io.IOException)358 FileOutputStream (java.io.FileOutputStream)161 Test (org.junit.Test)161 File (java.io.File)96 BufferedOutputStream (java.io.BufferedOutputStream)52 ObjectOutput (java.io.ObjectOutput)47 OutputStream (java.io.OutputStream)37 HashMap (java.util.HashMap)37 ArrayList (java.util.ArrayList)33 FileInputStream (java.io.FileInputStream)25 InputStream (java.io.InputStream)23 FileNotFoundException (java.io.FileNotFoundException)22 Serializable (java.io.Serializable)17 GZIPOutputStream (java.util.zip.GZIPOutputStream)16 Test (org.testng.annotations.Test)15 NotSerializableException (java.io.NotSerializableException)14