Monday, November 9, 2009

Re: [Java] Problem with File I/O

 



________________________________
From: mas.kosumo <mas.kosumo@yahoo.com>
To: Java_Official@yahoogroups.com
Sent: Sun, November 8, 2009 5:03:26 AM
Subject: [Java] Problem with File I/O

Hi guys,

I have a problem with my program. I tried to make a simple program to download pdf file from internet. First, I tried to use it for downloading text and html file, it works well. but, it didn't work with pdf file. the program could produce output file, but it can't be opened.

Here is the code snippet:

java.io.BufferedInp utStream in = new java.io.BufferedInp utStream( new java.net.URL( "http://www.digilife .be/quickreferen ces/QRC/JAVA% 20Quick%20Refere nce.pdf").openStream( ));
java.io.FileOutputS tream fos = new java.io.FileOutputS tream("output. pdf");
java.io.BufferedOut putStream bout = new BufferedOutputStrea m(fos,1024) ;
byte data[] = new byte[1024];
while(in.read( data,0,1024) >=0)
{
bout.write(data) ;
}
bout.close() ;
in.close();

Anyone could give me the clue? BTW, is there any website that provide free java library, especially one that support file operation (download, upload, etc)?

Thanks in advance.

The web http://www.apache.org


[Non-text portions of this message have been removed]

__._,_.___
Visit http://aiaiai.com or http://jgame.org for more groups to join.
Java Official Group is created for the following topics: Java 2 Enterprise Edition - J2EE, Java 2 Standard Edition - J2SE, Java 2 Micro Edition - J2ME, XML, XSL, XSD, XPATH, Web Services, Jini, JXTA for all type of Java Geeks.
Whoever posts spam / ads / job related message will be BANNED IMMEDIATELY
.

__,_._,___

No comments:

Post a Comment