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

byte[]load(File file)
load
try {
    FileInputStream fis = new FileInputStream(file);
    byte[] data = loadBytesFromStream(fis);
    fis.close();
    return data;
} catch (IOException ioe) {
    ioe.printStackTrace();
    return null;
...
byte[]load(File file)
load
InputStream in = new FileInputStream(file);
byte[] content = load(in, (int) file.length());
in.close();
return content;
byte[]load(File file)
load
InputStream in = new FileInputStream(file);
try {
    in = new BufferedInputStream(in);
    return toByteArray(in, -1);
} finally {
    in.close();
Stringload(String file)
load
FileInputStream fin = new FileInputStream(file);
byte[] b = new byte[fin.available()];
fin.read(b);
String str = new String(b);
fin.close();
return str;
StringloadContents(File file)

Loads a file contents as a String using platform encoding.

final StringBuilder contents = new StringBuilder();
final BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));
try {
    final byte[] buffer = new byte[1024];
    int read = in.read(buffer);
    while (read >= 0) {
        contents.append(new String(buffer, 0, read));
        read = in.read(buffer);
...
byte[]loadData(File f)
load Data
byte[] data = null;
InputStream br = new FileInputStream(f);
byte[] tmp = new byte[8192];
int num = 0;
int len = 0;
try {
    while ((num = br.read(tmp)) > 0) {
        if (data == null) {
...
voidloadFolderFromJar(String path)
load Folder From Jar
InputStream in = null;
FileOutputStream fos = null;
try {
    File dir = new File(path);
    for (File nextFile : dir.listFiles()) {
        in = new FileInputStream(nextFile.toString());
        File temp = new File("cdatafiles" + File.separator + nextFile.getName());
        temp.getParentFile().mkdirs();
...
InputStreamloadRes(String res)
load Res
InputStream is = null;
if (res.startsWith("file:")) {
    is = new FileInputStream(res.substring("file:".length()));
} else if (res.startsWith("classpath:")) {
    res = res.substring("classpath:".length());
    is = Thread.currentThread().getContextClassLoader().getResourceAsStream(res);
} else {
    is = Thread.currentThread().getContextClassLoader().getResourceAsStream(res);
...
voidloadStackableItems(String fileName)
load Stackable Items
try {
    int stackable;
    int counter = 0;
    FileInputStream dataIn = new FileInputStream(new File(fileName));
    while ((stackable = dataIn.read()) != -1) {
        stackableItems[counter] = (stackable == 1);
        counter++;
    dataIn.close();
} catch (IOException ex) {
    ex.printStackTrace();
StringloadTxtFile(String fileName)
load Txt File
byte[] bfs = loadFile(fileName);
String ret = new String(bfs, "UTF-8");
return ret;