Snippets tagged “inputstream”
7 snippets use this tag.
- Convert InputStream to byte array in JavaJava
To convert an InputStream to a byte array in Java, you can use the readAllBytes() method of the java.nio.file.Files class from the java.nio.file package.
- Easy way to write contents of a Java InputStream to an OutputStreamJava
One way to write the contents of a Java InputStream to an OutputStream is to use the read and write methods of the InputStream and OutputStream classes.
- How do I convert a String to an InputStream in Java?Java
To convert a String to an InputStream in Java, you can use the ByteArrayInputStream class, which allows you to create an InputStream from a byte array.
- How do I load a file from resource folder?Java
To load a file from the resource folder in a Java application, you can use the ClassLoader and getResourceAsStream method.
- How do I read / convert an InputStream into a String in Java?Java
There are several ways to read an InputStream and convert it to a String in Java. One way is to use the BufferedReader and InputStreamReader classes to read the InputStream line by line, and use a StringBuilder to construct the final String:
- How to read text file from classpath in Java?Java
To read a text file from the classpath in Java, you can use the getResourceAsStream method of the ClassLoader class to get an InputStream for the file, and then use a BufferedReader to read the contents of the file.
- Reading Properties file in JavaJava
To read a properties file in Java, you can use the Properties class from the java.util package.