Examples of ObjectOutput


Examples of java.io.ObjectOutput

        rule.setSalience( 42 );
        rule.setLoadOrder( 22 );

        // Serialize to a byte array
        ByteArrayOutputStream bos = new ByteArrayOutputStream( );
        ObjectOutput out = new ObjectOutputStream( bos );
        out.writeObject( rule );
        out.close( );

        // Get the bytes of the serialized object
        byte[] bytes = bos.toByteArray( );

        // Deserialize from a byte array
View Full Code Here

Examples of java.io.ObjectOutput

        ruleSet.addRule( rule1 );
        ruleSet.addRule( rule2 );

        // Serialize to a byte array
        ByteArrayOutputStream bos = new ByteArrayOutputStream( );
        ObjectOutput out = new ObjectOutputStream( bos );
        out.writeObject( ruleSet );
        out.close( );

        // Get the bytes of the serialized object
        byte[] bytes = bos.toByteArray( );

        // Deserialize from a byte array
View Full Code Here

Examples of java.io.ObjectOutput

  public void testSerializable() throws IOException {
    Directory dir = new RAMDirectory();
    ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
    assertEquals("initially empty", 0, bos.size());
    ObjectOutput out = new ObjectOutputStream(bos);
    int headerSize = bos.size();
    out.writeObject(dir);
    out.close();
    assertTrue("contains more then just header", headerSize < bos.size());
  }
View Full Code Here

Examples of java.io.ObjectOutput

        assertEquals("text/plain; charset=\"iso(8859)\"", mimeType.toString());
    }

    public void testWriteExternal() throws MimeTypeParseException, IOException {
        mimeType = new MimeType("text/plain; charset=iso8859-1");
        mimeType.writeExternal(new ObjectOutput() {
            public void writeUTF(String str) {
                assertEquals("text/plain; charset=iso8859-1", str);
            }

            public void close() {
View Full Code Here

Examples of java.io.ObjectOutput

  }

  private void saveTimeStampCache(FileTimeStampChecker fileStampCheck) {
    try {
      File file = getSerializationTmpFile();
      ObjectOutput out = new ObjectOutputStream( new FileOutputStream( file ) );
      out.writeObject( fileStampCheck );
      out.close();
      context.logMessage(
          Diagnostic.Kind.OTHER, "Serialized " + fileStampCheck + " into " + file.getAbsolutePath()
      );
    }
    catch ( IOException e ) {
View Full Code Here

Examples of java.io.ObjectOutput

 
  public static void serializeToFile(Object obj, String filename){
    try{
      OutputStream file = new FileOutputStream(filename);
      OutputStream buffer = new BufferedOutputStream(file);
      ObjectOutput output = new ObjectOutputStream(buffer);
      output.writeObject(obj);
      output.close();
    }catch(IOException ex){
      throw new RuntimeException("Error while serializing " + MyUtilities.getStackTrace(ex));
    }
  }
View Full Code Here

Examples of java.io.ObjectOutput

      return retValue;
   }

   public ByteBuffer objectToBuffer(Object o) throws IOException {
      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
      ObjectOutput out = new ObjectOutputStream(baos);

      //now marshall the contents of the object
      objectToObjectStream(o, out);
      out.close();
      // and return bytes.
      return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
   }
View Full Code Here

Examples of java.io.ObjectOutput

      return bytes;
   }

   public ByteBuffer objectToBuffer(Object o) throws IOException {
      ExposedByteArrayOutputStream baos = new ExposedByteArrayOutputStream(128);
      ObjectOutput marshaller = startObjectOutput(baos);
      objectToObjectStream(o, marshaller);
      finishObjectOutput(marshaller);
      return new ByteBuffer(baos.getRawBuffer(), 0, baos.size());
   }
View Full Code Here

Examples of java.io.ObjectOutput

    }

    protected byte[] serializeOut(final Object obj) throws IOException {
        // Serialize to a byte array
        final ByteArrayOutputStream bos = new ByteArrayOutputStream();
        final ObjectOutput out = new ObjectOutputStream( bos );
        out.writeObject( obj );
        out.close();

        // Get the bytes of the serialized object
        final byte[] bytes = bos.toByteArray();
        return bytes;
    }
View Full Code Here

Examples of java.io.ObjectOutput

          else if(field.getAnnotation(Embedded.class) != null){
            value = JsonSerializer.serialize(value).toString();
          }
          else if(field.getAnnotation(Polymorphic.class) != null){
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            ObjectOutput out;
            try {
              out = new ObjectOutputStream(bos);
              out.writeObject(value);
              out.close();
            } catch (IOException e) {
              throw new SienaException(e);
            }  
           
            value = bos.toByteArray();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.