Package com.jalios.io

Class NIOUtil

java.lang.Object
com.jalios.io.NIOUtil

public class NIOUtil extends Object
This class provides a set of static methods which perform various i/o operations based on the java.nio package.
Since:
jcms-5.0.0
Author:
Olivier Dedieu
  • Constructor Details

    • NIOUtil

      public NIOUtil()
  • Method Details

    • copyFile

      public static void copyFile(String filename1, String filename2) throws IOException
      Copy filename1 into filename2 (mkdirs for filename2)
      Parameters:
      filename1 - the source file
      filename2 - the target file
      Throws:
      IOException - if an exception occurs
      Since:
      jcms-5.0.5
    • copyFile

      public static void copyFile(File f1, File f2) throws IOException
      Copy f1 into f2 (mkdirs for f2). This method is about 25% faster than IOUtil.copyFile()
      Parameters:
      f1 - the source file
      f2 - the target file
      Throws:
      IOException - if an exception occurs
      Since:
      jcms-5.0.5
    • goToLine

      public static boolean goToLine(ByteBuffer buffer, long line)
      Move the position of the given ByteBuffer to the given line.
      Parameters:
      buffer - the buffer to move the position.
      line - the line to be reached
      Returns:
      true if the line has been reached, false otherwite (line out of buffer size)
      Since:
      jcms-5.0.0
    • clean

      public static void clean(MappedByteBuffer buffer) throws Exception
      Throws:
      Exception
    • countLines

      public static long countLines(File file) throws IOException
      Counts the line of the given file
      Parameters:
      file - the file
      Returns:
      the line count.
      Throws:
      IOException - if an exception occurs
      Since:
      jcms-10.0.8