Use FileInputStream
:
InputStream is = new FileInputStream("/res/example.xls");
But never read from raw file input stream as this is terribly slow. Wrap it with buffering decorator first:
new BufferedInputStream(is);
BTW leading slash means that the path is absolute, not relative.
Related Contents:
- How do I read / convert an InputStream into a String in Java?
- byte[] to file in Java
- What is InputStream & Output Stream? Why and when do we use them?
- Guava equivalent for IOUtils.toString(InputStream)
- Most efficient way to create InputStream from OutputStream
- How to chain multiple different InputStreams into one InputStream
- How to load a classpath resource to an array of byte?
- How can I read a large text file line by line using Java?
- How to read all files in a folder from Java?
- Get an OutputStream into a String
- Easy way to write contents of a Java InputStream to an OutputStream
- How to convert OutputStream to InputStream?
- javac is not recognized as an internal or external command, operable program or batch file [closed]
- Create whole path automatically when writing to a new file
- Java: Path vs File
- Check if a path represents a file or a folder
- Is it possible to read from a InputStream with a timeout?
- Is it possible to create a File object from InputStream
- Write string to output stream
- Does Java have a path joining method? [duplicate]
- Ant path style patterns
- Can you explain the HttpURLConnection connection process?
- InputStream from a URL
- Can we convert a byte array into an InputStream in Java?
- console.writeline and System.out.println
- read complete file without using loop in java
- How to get current working directory in Java?
- hadoop No FileSystem for scheme: file
- How to get resources directory path programmatically
- Listing files in a directory matching a pattern in Java [duplicate]
- How can I get a java.io.InputStream from a java.lang.String?
- Java’s createNewFile() – will it also create directories?
- How to check the extension of a Java 7 Path
- How can I check if an InputStream is empty without reading from it?
- Getting “java.nio.file.AccessDeniedException” when trying to write to a folder
- How to access a sub-file/folder in Java 7 java.nio.file.Path?
- Design pattern for “retrying” logic that failed?
- When to use ** (double star) in glob syntax within JAVA
- What’s the fastest way to read from System.in in Java?
- Use Cases and Examples of GoF Decorator Pattern for IO
- How to overwrite file via java nio writer?
- Why does InputStream#read() return an int and not a byte?
- How to check if InputStream is Gzipped?
- difference between flush and close function in case of filewriter in java
- How do relative file paths work in Eclipse?
- How does Java resolve a relative path in new File()?
- At what point does wrapping a FileOutputStream with a BufferedOutputStream make sense, in terms of performance?
- Setting up enviroment variables in Windows 10 to use java and javac
- FileInputStream vs FileReader
- How to read file from ZIP using InputStream?