Package net.sf.joafip.file.service.stream

Examples of net.sf.joafip.file.service.stream.FileOutputStreamNIO


  public void serialize(final File outputFile) throws MemInspectorException {
    final NodeForObjectTransferObjectFactory factory = NodeForObjectTransferObjectFactory
        .getInstance();
    try {
      final OutputStream out = new FileOutputStreamNIO(outputFile);
      final long rootNodeId = currentMemoryImage.getRootNode().getId().getValue();
      out.write((byte)(rootNodeId & 0xff));
      out.write((byte)((rootNodeId >> 8) & 0xff));
      out.write((byte)((rootNodeId >> 16) & 0xff));
      out.write((byte)((rootNodeId >> 24) & 0xff));
      out.write((byte)((rootNodeId >> 32) & 0xff));
      out.write((byte)((rootNodeId >> 40) & 0xff));
      out.write((byte)((rootNodeId >> 48) & 0xff));
      out.write((byte)((rootNodeId >> 56) & 0xff));
     
      final ITreeNodeForObjectVisitor visitor = new ITreeNodeForObjectVisitor() {
        public void beginVisit(final NodeForObject object,
            final boolean firstVisit) throws MemInspectorException {
          if (firstVisit) {
            try {
              final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
              final ObjectOutputStream objectOutputStream = new ObjectOutputStream(
                  byteArrayOutputStream);
              final NodeForObjectTO nodeForObjectTO = factory
                  .createNodeForObjectTO(object);
              objectOutputStream.writeObject(nodeForObjectTO);
              objectOutputStream.close();
              final byte[] byteArray = byteArrayOutputStream
                  .toByteArray();
              final int length = byteArray.length;
              out.write(length & 0xff);
              out.write((length >> 8) & 0xff);
              out.write((length >> 16) & 0xff);
              out.write((length >> 24) & 0xff);
              out.write(byteArray);
            } catch (IOException exception) {
              throw new MemInspectorException(exception);
            }
          }
        }

        public void endVisit(final NodeForObject object) {
          // no implementation
        }
      };
      visitCurrent(visitor);
      out.flush();
      out.close();
    } catch (FileNotFoundException exception) {
      throw new MemInspectorException(exception);
    } catch (IOException exception) {
      throw new MemInspectorException(exception);
    }
View Full Code Here


  public static void main(final String[] args) {
    try {
      final File file = new File("runtime/3gb.bin");
      file.delete();
      final MainWriteRead3GByteFileOutputStreamNIO main = new MainWriteRead3GByteFileOutputStreamNIO();
      final OutputStream outputStream = new FileOutputStreamNIO(file);
      System.out.println("write duration " + main.write(outputStream)
          + " mS");// NOPMD
      final InputStream inputStream = new FileInputStream(file);
      System.out.println("read duration " + main.read(inputStream)
          + " mS");// NOPMD
View Full Code Here

  @Override
  protected void open(final File directory) throws StoreException {
    exportFile = new File(directory, "export.xml");
    final OutputStream outputStream;
    try {
      outputStream = new FileOutputStreamNIO(exportFile);
    } catch (FileNotFoundException exception) {
      throw new StoreException(exception);
    }
    final BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(
        outputStream);
View Full Code Here

TOP

Related Classes of net.sf.joafip.file.service.stream.FileOutputStreamNIO

Copyright © 2018 www.massapicom. 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.