1InputStream pdf = // greate some input stream data
2try (FileOutputStream outputStream = new FileOutputStream(new File("/Users/kirkbrown/documents/my.pdf"))) {
3
4 int read;
5 byte[] bytes = new byte[1024];
6
7 while ((read = pdf.read(bytes)) != -1) {
8 outputStream.write(bytes, 0, read);
9 }
10 }
1 try{
2 FileInputStream fin=new FileInputStream("D:\\testout.txt");
3 int i=0;
4 while((i=fin.read())!=-1){
5 System.out.print((char)i);
6 }
7 fin.close();
8 }catch(Exception e){System.out.println(e);}