Answers for "how to convert inputstream to fileinputstream in java"

0

write input stream to file java

InputStream pdf = // greate some input stream data
try (FileOutputStream outputStream = new FileOutputStream(new File("/Users/kirkbrown/documents/my.pdf"))) {

			int read;
			byte[] bytes = new byte[1024];

			while ((read = pdf.read(bytes)) != -1) {
				outputStream.write(bytes, 0, read);
			}
		}
Posted by: Guest on October-22-2020
0

write files with FileOutPutStream java

@Test
public void givenWritingStringToFile_whenUsingFileOutputStream_thenCorrect() 
  throws IOException {
    String str = "Hello";
    FileOutputStream outputStream = new FileOutputStream(fileName);
    byte[] strToBytes = str.getBytes();
    outputStream.write(strToBytes);

    outputStream.close();
}
Posted by: Guest on November-28-2021

Code answers related to "how to convert inputstream to fileinputstream in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language