Package java.nio.channels

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


      FileChannel idxChannel = new FileOutputStream(tmpIdx).getChannel();
      OutputStream idxStream = Channels.newOutputStream(idxChannel);
      try {
        pw.writeIndex(idxStream);
      } finally {
        idxChannel.force(true);
        idxStream.close();
        idxChannel.close();
      }

      // rename the temporary files to real files
View Full Code Here


    }
    try {
      final FileChannel channel = openFile.getChannel();
      channel.position(channel.size());
      writeDocumentsToChannel(channel, documents);
      channel.force(true);
    } catch (IOException e) {
      logger.warning("I/O error writing to cache file "+ cacheFilename);
      return;
    }
  }
View Full Code Here

        bos.write(ByteBuffer.wrap(new byte[8]).putLong(version).array());
        bos.write(serialize(value));
        bos.close();
        tmp.renameTo(file);
      } finally {
        channel.force(false);
        fileLock.release();
        channel.close();
        raf.close();
      }
    } catch (Exception e) {
View Full Code Here

        bos.write(ByteBuffer.wrap(new byte[8]).putLong(version + 1).array());
        bos.write(serialize(value));
        bos.close();
        return tmp.renameTo(file);
      } finally {
        channel.force(false);
        fileLock.release();
        channel.close();
        raf.close();
      }
    } catch (Exception e) {
View Full Code Here

        while ( ( tCount += c2.transferFrom( c1, 0, size - tCount ) ) < size )
        {
        }

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

    @Nonnull
    public static String normalizePath( @Nonnull String path )
View Full Code Here

            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

            // And empty the journal
            FileOutputStream stream = new FileOutputStream( journal );
            FileChannel channel = stream.getChannel();
            channel.position( 0 );
            channel.force( true );
        }
    }


    /**
 
View Full Code Here

            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

            while (written < length) {
                written += fileChannel.write(byteBuffers);
            }
        }

        fileChannel.force(false);
        fileChannel.close();
        outputStream.close();
        isRenamed = true;
        return written == length;
    }
View Full Code Here

            int written = 0;
            while (written < size) {
                written += localfileChannel.write(byteBuffer);
            }
            buffer.readerIndex(buffer.readerIndex() + written);
            localfileChannel.force(false);
            localfileChannel.close();
            outputStream.close();
            completed = true;
        } finally {
            // Release the buffer as it was retained before and we not need a reference to it at all
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.