java file from inputstream code example
Example 1: java fileinputstream
try{
FileInputStream fin=new FileInputStream("D:\\testout.txt");
int i=0;
while((i=fin.read())!=-1){
System.out.print((char)i);
}
fin.close();
}catch(Exception e){System.out.println(e);}
Example 2: write input stream to file java
InputStream pdf =
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);
}
}