Java Utililty Methods FileInputStream Read

List of utility methods to do FileInputStream Read

Description

The list of methods to do FileInputStream Read are organized into topic(s).

Method

StringreadFile(String path)
read File
FileInputStream in = new FileInputStream(path);
String s = readStreamUTF8(in);
in.close();
return s;
byte[]readFile(String path)
Read whole data of a file.
InputStream is = null;
ByteArrayOutputStream baos = null;
try {
    is = new FileInputStream(path);
    baos = new ByteArrayOutputStream();
    byte[] buf = new byte[IOBUFSIZ];
    int len;
    while ((len = is.read(buf)) != -1) {
...
byte[]readFile(String path)
read file to byte array
final File file = new File(path);
if (!file.exists())
    throw new IOException("the path" + path + " is not exists");
final FileInputStream templateImageData = new FileInputStream(file);
final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte[] cache = new byte[255];
int len = 0;
while (-1 != (len = templateImageData.read(cache))) {
...
StringreadFile(String path)
read File
File file = new File(path);
FileInputStream fis = new FileInputStream(file);
byte[] data = new byte[(int) file.length()];
fis.read(data);
fis.close();
return new String(data, "UTF-8");
byte[]readFile(String path)
read File
return readStream(new FileInputStream(path));
StringreadFile(String path)
read File
File f = new File(path);
if (!f.isFile())
    return "";
FileInputStream s;
try {
    s = new FileInputStream(f);
} catch (FileNotFoundException e) {
    return "";
...
byte[]readFile(String path)
Reads file and return the byte Array
File file = new File(path);
byte[] fileData = new byte[(int) file.length()];
DataInputStream dis;
try {
    dis = new DataInputStream((new FileInputStream(file)));
    dis.readFully(fileData);
    dis.close();
} catch (FileNotFoundException e) {
...
byte[]readFile(String path, long offset)
read File
return readFile(path, offset, -1);
voidreadFile(String path, Properties store)
Reads data from a properties file to a Properties object.
checkNullReference(path, store);
store.load(new FileInputStream(path));
StringreadFile(String path, String encoding)
read File
byte[] byteArray = loadByteArray(path);
String fileContents = new String(byteArray, encoding);
return fileContents;