| Modifier and Type | Method and Description |
|---|---|
static List<String> |
head(File f)
Returns the first (up to 10) lines of the given
File using
the system's default charset. |
static List<String> |
head(File f,
Charset charset)
Returns the first (up to 10) lines of the given
File using
the specified charset. |
static List<String> |
head(File f,
int n)
Returns the first (up to
n) lines of the given File
using the system's default charset. |
static List<String> |
head(File f,
int n,
Charset charset)
Returns the first (up to
n) lines of the given File
using the specified charset. |
static BufferedReader |
newReader(File f)
Returns a new
BufferedReader to read the given File
using the system's default charset. |
static BufferedReader |
newReader(File f,
Charset charset)
Returns a new
BufferedReader to read the given File
using the specified charset. |
static BufferedWriter |
newWriter(File f,
Charset charset,
WriteOption... options)
Returns a new
BufferedWriter to write to the given
File using the specified charset. |
static BufferedWriter |
newWriter(File f,
WriteOption... options)
Returns a new
BufferedWriter to write to the given
File using the system's default charset. |
static String |
read(File f)
Reads the whole content of the given
File as a String
using the system's default charset. |
static String |
read(File f,
Charset charset)
Reads the whole content of the given
File as a String
using the specified charset. |
static List<String> |
readLines(File f)
Reads all the lines from the given
File using the system's
default charset. |
static List<String> |
readLines(File f,
Charset charset)
Reads all the lines from the given
File using the specified
charset. |
static List<String> |
tail(File f)
Returns the last (up to 10) lines of the given
File using the
system's default charset. |
static List<String> |
tail(File f,
Charset charset)
Returns the last (up to 10) lines of the given
File using the
specified charset. |
static List<String> |
tail(File f,
int n)
Returns the last (up to n) lines of the given
File using the
system's default charset. |
static List<String> |
tail(File f,
int n,
Charset charset)
Returns the last (up to n) lines of the given
File using the
specified charset. |
public static List<String> head(File f) throws IOException
File using
the system's default charset. Named after the Unix command of the
same name.f - the File to read.File.NullPointerException - if f is null.IOException - if f does not exist, or if it is a
directory rather than a regular file, or if it can't be read.SecurityException - if a security manager exists and denies
read access to f.public static List<String> head(File f, Charset charset) throws IOException
File using
the specified charset. Named after the Unix command of the same name.f - the File to read.charset - the charset to use.File.NullPointerException - if f is null.IOException - if f does not exist, or if it is a
directory rather than a regular file, or if it can't be read.SecurityException - if a security manager exists and denies
read access to f.public static List<String> head(File f, int n) throws IOException
n) lines of the given File
using the system's default charset. Named after the Unix command of
the same name.f - the File to read.n - the maximum number of lines to read.File.NullPointerException - if f is null.IllegalArgumentException - if n is negative.IOException - if f does not exist, or if it is a
directory rather than a regular file, or if it can't be read.SecurityException - if a security manager exists and denies
read access to f.public static List<String> head(File f, int n, Charset charset) throws IOException
n) lines of the given File
using the specified charset. Named after the Unix command of the same
name.f - the File to read.n - the maximum number of lines to read.charset - the charset to use.File.NullPointerException - if one of the arguments is null.IllegalArgumentException - if n is negative.IOException - if f does not exist, or if it is a
directory rather than a regular file, or if it can't be read.SecurityException - if a security manager exists and denies
read access to f.public static List<String> tail(File f) throws IOException
File using the
system's default charset. Named after the Unix command of the same
name.f - the File to read.File.NullPointerException - if f is null.IOException - if f does not exist, or if it is a
directory rather than a regular file, or if it can't be read.SecurityException - if a security manager exists and denies
read access to f.public static List<String> tail(File f, Charset charset) throws IOException
File using the
specified charset. Named after the Unix command of the same name.f - the File to read.charset - the charset to use.File.NullPointerException - if one of the arguments is null.IOException - if f does not exist, or if it is a
directory rather than a regular file, or if it can't be read.SecurityException - if a security manager exists and denies
read access to f.public static List<String> tail(File f, int n) throws IOException
File using the
system's default charset. Named after the Unix command of the same
name.f - the File to read.n - the maximum number of lines to read.File.NullPointerException - if f is null.IllegalArgumentException - if n is negative.IOException - if f does not exist, or if it is a
directory rather than a regular file, or if it can't be read.SecurityException - if a security manager exists and denies
read access to f.public static List<String> tail(File f, int n, Charset charset) throws IOException
File using the
specified charset. Named after the Unix command of the same name.f - the File to read.n - the maximum number of lines to read.charset - the charset to use.File.NullPointerException - if one of the arguments is null.IllegalArgumentException - if n is negative.IOException - if f does not exist, or if it is a
directory rather than a regular file, or if it can't be read.SecurityException - if a security manager exists and denies
read access to f.public static BufferedReader newReader(File f) throws FileNotFoundException
BufferedReader to read the given File
using the system's default charset.f - the file to read from.BufferedReader to read the given File.NullPointerException - if f is null.FileNotFoundException - if f doesn't exist, or if it is
a directory rather than a regular file, or if it can't be opened
for reading.SecurityException - if a security manager exists and denies
read access to f.public static BufferedReader newReader(File f, Charset charset) throws FileNotFoundException
BufferedReader to read the given File
using the specified charset.f - the file to read from.charset - the charset to use.BufferedReader to read the given File.NullPointerException - if one of the arguments is null.FileNotFoundException - if f doesn't exist, or if it is
a directory rather than a regular file, or if it can't be opened
for reading.SecurityException - if a security manager exists and denies
read access to f.public static BufferedWriter newWriter(File f, WriteOption... options) throws IOException
BufferedWriter to write to the given
File using the system's default charset.f - the file to write to.options - the write options.BufferedWriter to write to the given File.NullPointerException - if one of the arguments is null.IllegalArgumentException - if incompatible options are given.FileNotFoundException - if f exists but is a directory
rather than a regular file, or if it does not exist but cannot
be created, or if it cannot be opened for any other reason.IOException - if the WriteOption.CREATE option is given
and the specified file already exists.SecurityException - if a security manager exists and denies
write access to f.public static BufferedWriter newWriter(File f, Charset charset, WriteOption... options) throws IOException
BufferedWriter to write to the given
File using the specified charset.f - the file to write to.charset - the charset to use.options - the write options.BufferedWriter to write to the given File.NullPointerException - if one of the arguments is null.IllegalArgumentException - if incompatible options are given.FileNotFoundException - if f exists but is a directory
rather than a regular file, or if it does not exist but cannot
be created, or if it cannot be opened for any other reason.IOException - if the WriteOption.CREATE option is given
and the specified file already exists.SecurityException - if a security manager exists and denies
write access to f.public static String read(File f) throws IOException
File as a String
using the system's default charset.f - the file to read.String.NullPointerException - if f is null.IOException - if f does not exist, or if it is a
directory rather than a regular file, or if it can't be read.SecurityException - if a security manager exists and denies
read access to f.public static String read(File f, Charset charset) throws IOException
File as a String
using the specified charset.f - the file to read.charset - the charset to use.String.NullPointerException - if one of the arguments is null.IOException - if f does not exist, or if it is a
directory rather than a regular file, or if it can't be read.SecurityException - if a security manager exists and denies
read access to f.public static List<String> readLines(File f) throws IOException
File using the system's
default charset. Note that the returned List is immutable.f - the file to read.NullPointerException - if f is null.IOException - if f does not exist, or if it is a
directory rather than a regular file, or if it can't be read.SecurityException - if a security manager exists and denies
read access to f.public static List<String> readLines(File f, Charset charset) throws IOException
File using the specified
charset. Note that the returned List is immutable.f - the file to read.charset - the charset to use.NullPointerException - if one of the arguments is null.IOException - if f does not exist, or if it is a
directory rather than a regular file, or if it can't be read.SecurityException - if a security manager exists and denies
read access to f.Copyright © 2012–2015. All rights reserved.