Package java.nio.channels

Examples of java.nio.channels.FileChannel.force()


            bb.flip();
            ch.write( bb );
        }

        // Flush to the disk for real
        ch.force( true );
        ch.close();

        // Rename the current file to save a backup
        File backupFile = File.createTempFile( "mavibot", null, baseDirectory );
        file.renameTo( backupFile );
View Full Code Here


                                              .getSimpleName(),
                                          "testCompressDecompress");
    final FileOutputStream lFileOutputStream = new FileOutputStream(lTempFile);
    final FileChannel lChannel = lFileOutputStream.getChannel();
    lChannel.write(lDmImageDecompressed);
    lChannel.force(false);
    lFileOutputStream.close();
  }

  private ByteBuffer loadRawImage() throws FileNotFoundException
  {
View Full Code Here

        try
        {
            sourceChannel = new FileInputStream(source).getChannel();
            targetChannel = new FileOutputStream(dest).getChannel();
            sourceChannel.transferTo(0, sourceChannel.size(), targetChannel);
            targetChannel.force(true);
        } finally
        {
            if (sourceChannel != null) sourceChannel.close();
            if (targetChannel != null) targetChannel.close();
        }
View Full Code Here

            }
            if (written <= 0 && size > 0) {
                throw new IOException("Copying to new location " + rlocFile + " failed");
            }
        } finally {
            newFc.force(true);
            newFc.close();
        }
        // delete old.idx
        fc.close();
        if (!delete()) {
View Full Code Here

        if (wc.getFSyncRefFiles()) {
          FileChannel fc = out.getChannel();
          ByteBuffer buf = ByteBuffer.wrap(rec);
          while (0 < buf.remaining())
            fc.write(buf);
          fc.force(true);
        } else {
          out.write(rec);
        }
      } finally {
        out.close();
View Full Code Here

        long tCount = 0, size = c1.size();
        while ( ( tCount += c2.transferFrom( c1, 0, size - tCount ) ) < size )
            ;

        c1.close();
        c2.force( true );
        c2.close();
    }

    public static String normalizePath( String path )
    {
View Full Code Here

      @Override
      public void flush(File f) throws IOException {
         FileChannel channel = streams.get(f.getPath());
         if (channel != null)
            channel.force(false);
      }

      @Override
      public void purge(File f) throws IOException {
         // Avoid a delete per-se because it hampers any fsync-like functionality
View Full Code Here

               for (Map.Entry<String, FileChannel> entry : streams.entrySet()) {
                  if (trace)
                     log.tracef("Flushing channel in %s", entry.getKey());
                  FileChannel channel = entry.getValue();
                  try {
                     channel.force(true);
                  } catch (IOException e) {
                     if (trace)
                        log.tracef(e, "Error flushing output stream for %s", entry.getKey());
                     flushErrors.putIfAbsent(entry.getKey(), e);
                     // If an error is encountered, close it. Next time it's used,
View Full Code Here

    }

    public byte[] readLinearData(PdfObjectReader currentPdfFile, File tempURLFile, InputStream is, PdfDecoder pdfDecoder) throws IOException {

        final FileChannel fos = new RandomAccessFile(tempURLFile,"rws").getChannel();
        fos.force(true);

        final ByteArrayOutputStream bos=new ByteArrayOutputStream(8192);

        // Download buffer
        byte[] buffer = new byte[4096];
View Full Code Here

      if (wc.getFSyncRefFiles()) {
        FileChannel fc = out.getChannel();
        ByteBuffer buf = ByteBuffer.wrap(rec);
        while (0 < buf.remaining())
          fc.write(buf);
        fc.force(true);
      } else
        out.write(rec);
    } finally {
      out.close();
    }
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.