/** * Constructs a new {@code FileInputStream} that reads from {@code file}. * * @param file * the file from which this stream reads. * @throws FileNotFoundException * if {@code file} does not exist. */ public FileInputStream(File file) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.fd = IoBridge.open(file.getAbsolutePath(), O_RDONLY); this.shouldClose = true; guard.open("close"); }
/** * Constructs a new {@code FileOutputStream} that writes to {@code file}. * If {@code append} is true and the file already exists, it will be appended to; otherwise * it will be truncated. The file will be created if it does not exist. * * @throws FileNotFoundException if the file cannot be opened for writing. */ public FileOutputStream(File file, boolean append) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.mode = O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC); this.fd = IoBridge.open(file.getAbsolutePath(), mode); this.shouldClose = true; this.guard.open("close"); }
this.fd = IoBridge.open(file.getAbsolutePath(), flags);
public FileReader(String absolutePath) throws IOException { // We use IoBridge.open because callers might differentiate // between a FileNotFoundException and a general IOException. // // NOTE: This costs us an additional call to fstat(2) to test whether // "absolutePath" is a directory or not. We can eliminate it // at the cost of copying some code from IoBridge.open. try { fd = IoBridge.open(absolutePath, O_RDONLY); } catch (FileNotFoundException fnfe) { throw fnfe; } int capacity; try { final StructStat stat = Libcore.os.fstat(fd); // Like RAF & other APIs, we assume that the file size fits // into a 32 bit integer. capacity = (int) stat.st_size; if (capacity == 0) { unknownLength = true; capacity = 8192; } } catch (ErrnoException exception) { closeQuietly(fd); throw exception.rethrowAsIOException(); } bytes = new byte[capacity]; }
/** * Constructs a new {@code FileOutputStream} that writes to {@code file}. * If {@code append} is true and the file already exists, it will be appended to; otherwise * it will be truncated. The file will be created if it does not exist. * * @throws FileNotFoundException if the file cannot be opened for writing. */ public FileOutputStream(File file, boolean append) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.mode = O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC); this.fd = IoBridge.open(file.getAbsolutePath(), mode); this.shouldClose = true; this.guard.open("close"); }
/** * Constructs a new {@code FileInputStream} that reads from {@code file}. * * @param file * the file from which this stream reads. * @throws FileNotFoundException * if {@code file} does not exist. */ public FileInputStream(File file) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.fd = IoBridge.open(file.getAbsolutePath(), O_RDONLY); this.shouldClose = true; guard.open("close"); }
/** * Constructs a new {@code FileOutputStream} that writes to {@code file}. * If {@code append} is true and the file already exists, it will be appended to; otherwise * it will be truncated. The file will be created if it does not exist. * * @throws FileNotFoundException if the file cannot be opened for writing. */ public FileOutputStream(File file, boolean append) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.mode = O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC); this.fd = IoBridge.open(file.getAbsolutePath(), mode); this.shouldClose = true; this.guard.open("close"); }
/** * Constructs a new {@code FileInputStream} that reads from {@code file}. * * @param file * the file from which this stream reads. * @throws FileNotFoundException * if {@code file} does not exist. */ public FileInputStream(File file) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.fd = IoBridge.open(file.getAbsolutePath(), O_RDONLY); this.shouldClose = true; guard.open("close"); }
/** * Constructs a new {@code FileInputStream} that reads from {@code file}. * * @param file * the file from which this stream reads. * @throws FileNotFoundException * if {@code file} does not exist. */ public FileInputStream(File file) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.fd = IoBridge.open(file.getAbsolutePath(), O_RDONLY); this.shouldClose = true; guard.open("close"); }
/** * Constructs a new {@code FileOutputStream} that writes to {@code file}. * If {@code append} is true and the file already exists, it will be appended to; otherwise * it will be truncated. The file will be created if it does not exist. * * @throws FileNotFoundException if the file cannot be opened for writing. */ public FileOutputStream(File file, boolean append) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.mode = O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC); this.fd = IoBridge.open(file.getAbsolutePath(), mode); this.shouldClose = true; this.guard.open("close"); }
/** * Constructs a new {@code FileInputStream} that reads from {@code file}. * * @param file * the file from which this stream reads. * @throws FileNotFoundException * if {@code file} does not exist. */ public FileInputStream(File file) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.fd = IoBridge.open(file.getAbsolutePath(), O_RDONLY); this.shouldClose = true; guard.open("close"); }
/** * Constructs a new {@code FileOutputStream} that writes to {@code file}. * If {@code append} is true and the file already exists, it will be appended to; otherwise * it will be truncated. The file will be created if it does not exist. * * @throws FileNotFoundException if the file cannot be opened for writing. */ public FileOutputStream(File file, boolean append) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.mode = O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC); this.fd = IoBridge.open(file.getAbsolutePath(), mode); this.shouldClose = true; this.guard.open("close"); }
/** * Constructs a new {@code FileOutputStream} that writes to {@code file}. * If {@code append} is true and the file already exists, it will be appended to; otherwise * it will be truncated. The file will be created if it does not exist. * * @throws FileNotFoundException if the file cannot be opened for writing. */ public FileOutputStream(File file, boolean append) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.mode = O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC); this.fd = IoBridge.open(file.getAbsolutePath(), mode); this.shouldClose = true; this.guard.open("close"); }
/** * Constructs a new {@code FileInputStream} that reads from {@code file}. * * @param file * the file from which this stream reads. * @throws FileNotFoundException * if {@code file} does not exist. */ public FileInputStream(File file) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.fd = IoBridge.open(file.getAbsolutePath(), O_RDONLY); this.shouldClose = true; guard.open("close"); }
/** * Constructs a new {@code FileInputStream} that reads from {@code file}. * * @param file * the file from which this stream reads. * @throws FileNotFoundException * if {@code file} does not exist. */ public FileInputStream(File file) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.fd = IoBridge.open(file.getAbsolutePath(), O_RDONLY); this.shouldClose = true; guard.open("close"); }
/** * Constructs a new {@code FileOutputStream} that writes to {@code file}. * If {@code append} is true and the file already exists, it will be appended to; otherwise * it will be truncated. The file will be created if it does not exist. * * @throws FileNotFoundException if the file cannot be opened for writing. */ public FileOutputStream(File file, boolean append) throws FileNotFoundException { if (file == null) { throw new NullPointerException("file == null"); } this.mode = O_WRONLY | O_CREAT | (append ? O_APPEND : O_TRUNC); this.fd = IoBridge.open(file.getAbsolutePath(), mode); this.shouldClose = true; this.guard.open("close"); }
public FileReader(String absolutePath) throws IOException { // We use IoBridge.open because callers might differentiate // between a FileNotFoundException and a general IOException. // // NOTE: This costs us an additional call to fstat(2) to test whether // "absolutePath" is a directory or not. We can eliminate it // at the cost of copying some code from IoBridge.open. try { fd = IoBridge.open(absolutePath, O_RDONLY); } catch (FileNotFoundException fnfe) { throw fnfe; } int capacity; try { final StructStat stat = Libcore.os.fstat(fd); // Like RAF & other APIs, we assume that the file size fits // into a 32 bit integer. capacity = (int) stat.st_size; if (capacity == 0) { unknownLength = true; capacity = 8192; } } catch (ErrnoException exception) { closeQuietly(fd); throw exception.rethrowAsIOException(); } bytes = new byte[capacity]; }
public FileReader(String absolutePath) throws IOException { // We use IoBridge.open because callers might differentiate // between a FileNotFoundException and a general IOException. // // NOTE: This costs us an additional call to fstat(2) to test whether // "absolutePath" is a directory or not. We can eliminate it // at the cost of copying some code from IoBridge.open. try { fd = IoBridge.open(absolutePath, O_RDONLY); } catch (FileNotFoundException fnfe) { throw fnfe; } int capacity; try { final StructStat stat = Libcore.os.fstat(fd); // Like RAF & other APIs, we assume that the file size fits // into a 32 bit integer. capacity = (int) stat.st_size; if (capacity == 0) { unknownLength = true; capacity = 8192; } } catch (ErrnoException exception) { closeQuietly(fd); throw exception.rethrowAsIOException(); } bytes = new byte[capacity]; }
public FileReader(String absolutePath) throws IOException { // We use IoBridge.open because callers might differentiate // between a FileNotFoundException and a general IOException. // // NOTE: This costs us an additional call to fstat(2) to test whether // "absolutePath" is a directory or not. We can eliminate it // at the cost of copying some code from IoBridge.open. try { fd = IoBridge.open(absolutePath, O_RDONLY); } catch (FileNotFoundException fnfe) { throw fnfe; } int capacity; try { final StructStat stat = Libcore.os.fstat(fd); // Like RAF & other APIs, we assume that the file size fits // into a 32 bit integer. capacity = (int) stat.st_size; if (capacity == 0) { unknownLength = true; capacity = 8192; } } catch (ErrnoException exception) { closeQuietly(fd); throw exception.rethrowAsIOException(); } bytes = new byte[capacity]; }
public FileReader(String absolutePath) throws IOException { // We use IoBridge.open because callers might differentiate // between a FileNotFoundException and a general IOException. // // NOTE: This costs us an additional call to fstat(2) to test whether // "absolutePath" is a directory or not. We can eliminate it // at the cost of copying some code from IoBridge.open. try { fd = IoBridge.open(absolutePath, O_RDONLY); } catch (FileNotFoundException fnfe) { throw fnfe; } int capacity; try { final StructStat stat = Libcore.os.fstat(fd); // Like RAF & other APIs, we assume that the file size fits // into a 32 bit integer. capacity = (int) stat.st_size; if (capacity == 0) { unknownLength = true; capacity = 8192; } } catch (ErrnoException exception) { closeQuietly(fd); throw exception.rethrowAsIOException(); } bytes = new byte[capacity]; }