• Home
  • Raw
  • Download

Lines Matching refs:file

65   public static BufferedReader newReader(File file, Charset charset)  in newReader()  argument
68 new InputStreamReader(new FileInputStream(file), charset)); in newReader()
79 public static BufferedWriter newWriter(File file, Charset charset) in newWriter() argument
82 new OutputStreamWriter(new FileOutputStream(file), charset)); in newWriter()
93 final File file) { in newInputStreamSupplier() argument
94 Preconditions.checkNotNull(file); in newInputStreamSupplier()
97 return new FileInputStream(file); in newInputStreamSupplier()
110 File file) {
111 return newOutputStreamSupplier(file, false);
124 final File file, final boolean append) {
125 Preconditions.checkNotNull(file);
128 return new FileOutputStream(file, append);
141 public static InputSupplier<InputStreamReader> newReaderSupplier(File file,
143 return CharStreams.newReaderSupplier(newInputStreamSupplier(file), charset);
154 public static OutputSupplier<OutputStreamWriter> newWriterSupplier(File file,
156 return newWriterSupplier(file, charset, false);
169 public static OutputSupplier<OutputStreamWriter> newWriterSupplier(File file,
171 return CharStreams.newWriterSupplier(newOutputStreamSupplier(file, append),
184 public static byte[] toByteArray(File file) throws IOException {
185 Preconditions.checkArgument(file.length() <= Integer.MAX_VALUE);
186 if (file.length() == 0) {
188 return ByteStreams.toByteArray(newInputStreamSupplier(file));
191 byte[] b = new byte[(int) file.length()];
193 InputStream in = new FileInputStream(file);
213 public static String toString(File file, Charset charset) throws IOException {
214 return new String(toByteArray(file), charset.name());
428 public static void touch(File file) throws IOException {
429 if (!file.createNewFile()
430 && !file.setLastModified(System.currentTimeMillis())) {
431 throw new IOException("Unable to update modification time of " + file);
484 for (File file : files) {
485 deleteRecursively(file);
500 public static void deleteRecursively(File file) throws IOException {
501 if (file.isDirectory()) {
502 deleteDirectoryContents(file);
504 if (!file.delete()) {
505 throw new IOException("Failed to delete " + file);
519 public static String readFirstLine(File file, Charset charset)
521 return CharStreams.readFirstLine(Files.newReaderSupplier(file, charset));
534 public static List<String> readLines(File file, Charset charset)
536 return CharStreams.readLines(Files.newReaderSupplier(file, charset));
549 public static <T> T readLines(File file, Charset charset,
551 return CharStreams.readLines(Files.newReaderSupplier(file, charset),
566 public static <T> T readBytes(File file, ByteProcessor<T> processor)
568 return ByteStreams.readBytes(newInputStreamSupplier(file), processor);
581 public static long getChecksum(File file, Checksum checksum)
583 return ByteStreams.getChecksum(newInputStreamSupplier(file), checksum);
596 public static byte[] getDigest(File file, MessageDigest md)
598 return ByteStreams.getDigest(newInputStreamSupplier(file), md);
617 public static MappedByteBuffer map(File file) throws IOException {
618 return map(file, MapMode.READ_ONLY);
639 public static MappedByteBuffer map(File file, MapMode mode)
641 if (!file.exists()) {
642 throw new FileNotFoundException(file.toString());
644 return map(file, mode, file.length());
668 public static MappedByteBuffer map(File file, MapMode mode, long size)
671 new RandomAccessFile(file, mode == MapMode.READ_ONLY ? "r" : "rw");