Package com.jalios.io
Class NIOUtil
- java.lang.Object
-
- com.jalios.io.NIOUtil
-
public class NIOUtil extends java.lang.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 Summary
Constructors Constructor Description NIOUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
clean(java.nio.MappedByteBuffer buffer)
static void
copyFile(java.io.File f1, java.io.File f2)
Copy f1 into f2 (mkdirs for f2).static void
copyFile(java.lang.String filename1, java.lang.String filename2)
Copy filename1 into filename2 (mkdirs for filename2)static long
countLines(java.io.File file)
Counts the line of the given filestatic boolean
goToLine(java.nio.ByteBuffer buffer, long line)
Move the position of the given ByteBuffer to the given line.
-
-
-
Method Detail
-
copyFile
public static void copyFile(java.lang.String filename1, java.lang.String filename2) throws java.io.IOException
Copy filename1 into filename2 (mkdirs for filename2)- Parameters:
filename1
- the source filefilename2
- the target file- Throws:
java.io.IOException
- if an exception occurs- Since:
- jcms-5.0.5
-
copyFile
public static void copyFile(java.io.File f1, java.io.File f2) throws java.io.IOException
Copy f1 into f2 (mkdirs for f2). This method is about 25% faster than IOUtil.copyFile()- Parameters:
f1
- the source filef2
- the target file- Throws:
java.io.IOException
- if an exception occurs- Since:
- jcms-5.0.5
-
goToLine
public static boolean goToLine(java.nio.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(java.nio.MappedByteBuffer buffer) throws java.lang.Exception
- Throws:
java.lang.Exception
-
countLines
public static long countLines(java.io.File file) throws java.io.IOException
Counts the line of the given file- Parameters:
file
- the file- Returns:
- the line count.
- Throws:
java.io.IOException
- if an exception occurs- Since:
- jcms-10.0.8
-
-