Home | History | Annotate | Download | only in util

Lines Matching refs:file

5  * you may not use this file except in compliance with the License.
19 import java.io.File;
24 * File I/O utilities.
31 * Reads the named file, translating {@link IOException} to a
34 * @param fileName {@code non-null;} name of the file to read
35 * @return {@code non-null;} contents of the file
38 File file = new File(fileName);
39 return readFile(file);
43 * Reads the given file, translating {@link IOException} to a
46 * @param file {@code non-null;} the file to read
47 * @return {@code non-null;} contents of the file
49 public static byte[] readFile(File file) {
50 if (!file.exists()) {
51 throw new RuntimeException(file + ": file not found");
54 if (!file.isFile()) {
55 throw new RuntimeException(file + ": not a file");
58 if (!file.canRead()) {
59 throw new RuntimeException(file + ": file not readable");
62 long longLength = file.length();
65 throw new RuntimeException(file + ": file too long");
71 FileInputStream in = new FileInputStream(file);
76 throw new RuntimeException(file + ": unexpected EOF");
83 throw new RuntimeException(file + ": trouble reading", ex);