MCPcopy Create free account
hub / github.com/davidgiven/luje / FileInputStream

Class FileInputStream

lib/java/io/FileInputStream.java:35–339  ·  view source on GitHub ↗

A specialized InputStream that reads from a file in the file system. All read requests made by calling methods in this class are directly forwarded to the equivalent function of the underlying operating system. Since this may induce some performance penalty, in particular if many small read

Source from the content-addressed store, hash-verified

33 * @see FileOutputStream
34 */
35public class FileInputStream extends InputStream implements Closeable {
36 /**
37 * The {@link FileDescriptor} representing this {@code FileInputStream}.
38 */
39 FileDescriptor fd;
40
41 // The unique file channel associated with this FileInputStream (lazily
42 // initialized).
43// private FileChannel channel;
44
45 private IFileSystem fileSystem = Platform.getFileSystem();
46
47 private static class RepositioningLock {
48 }
49
50 private Object repositioningLock = new RepositioningLock();
51
52 /**
53 * Constructs a new {@code FileInputStream} based on {@code file}.
54 *
55 * @param file
56 * the file from which this stream reads.
57 * @throws FileNotFoundException
58 * if {@code file} does not exist.
59 * @throws SecurityException
60 * if a {@code SecurityManager} is installed and it denies the
61 * read request.
62 */
63 public FileInputStream(File file) throws FileNotFoundException {
64 super();
65// SecurityManager security = System.getSecurityManager();
66// if (security != null) {
67// // For compatibility, nulls are passed to the manager.
68// String filePath = (null == file ? null : file.getPath());
69// security.checkRead(filePath);
70// }
71 if (file == null) {
72 // luni.4D=Argument must not be null
73 throw new NullPointerException(Messages.getString("luni.4D")); //$NON-NLS-1$
74 }
75 fd = new FileDescriptor();
76 fd.readOnly = true;
77 fd.descriptor = fileSystem.open(file.properPath(true),
78 IFileSystem.O_RDONLY);
79// channel = FileChannelFactory.getFileChannel(this, fd.descriptor,
80// IFileSystem.O_RDONLY);
81 }
82
83 /**
84 * Constructs a new {@code FileInputStream} on the {@link FileDescriptor}
85 * {@code fd}. The file must already be open, therefore no
86 * {@code FileNotFoundException} will be thrown.
87 *
88 * @param fd
89 * the FileDescriptor from which this stream reads.
90 * @throws NullPointerException
91 * if {@code fd} is {@code null}.
92 * @throws SecurityException

Callers

nothing calls this directly

Calls 1

getFileSystemMethod · 0.95

Tested by

no test coverage detected