public class FileUtils
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
getTailOfFile(java.lang.String pathToFile,
java.lang.Integer lines)
Reads and returns the last n lines from a given file as string.
|
static byte[] |
readByteArrayFromFile(java.io.File fileToRead,
long start,
long end)
Read a file off disk into a byte array with specified range
This can use lots of memory if you read a large file
|
static java.lang.String |
readStringFromFile(java.lang.String path)
Read a file off disk into a String and return it.
|
static void |
writeStringToFile(java.lang.String contents,
java.lang.String path)
Save a String to a file on disk using specified path.
|
public static void writeStringToFile(java.lang.String contents,
java.lang.String path)
contents - to save to file on diskpath - to save file to.public static java.lang.String readStringFromFile(java.lang.String path)
path - of file to read inpublic static byte[] readByteArrayFromFile(java.io.File fileToRead,
long start,
long end)
fileToRead - File to read part of into byte arraystart - index of readend - index of readpublic static java.lang.String getTailOfFile(java.lang.String pathToFile,
java.lang.Integer lines)
pathToFile - path to filelines - size of the tail