Hi All, I have this following requirement. I have a url for and Image. I want to write an Java Program which will make an URL Connection to that file read that file and recreate it in my hard disk. I have written the following program.. but The file created on my drive is blurred... Its not recreating the full GIF Image.. Please do help.. My Code. ======================================= public static void main(java.lang.String[] args) { // Insert code to start the application here. System.out.println("Started the process"); System.getProperties().put("proxySet", "true"); System.getProperties().put("proxyHost", "MyproxyServer"); System.getProperties().put("proxyPort", "81"); try { URLConnection urlConn = new URL("http://site.com/3572f15.gif") .openConnection(); InputStreamReader isr = new InputStreamReader(urlConn.getInputStream()); OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream("C:/oracle/img.gif")); if (contentLength == -1) { //do nothing. } else { char buffer[] = new char[contentLength]; isr.read(buffer); osw.write(buffer); osw.flush(); } isr.close(); osw.close(); System.out.println("Completed the process"); } catch (Exception e) { System.out.println("Error Occurred " + e.toString()); e.printStackTrace(); } } ============================== thanks in advance.. C Balajee [ February 12, 2002: Message edited by: C Balajee ]
Maciej Kolodziej
Greenhorn
Joined: Feb 11, 2002
Posts: 26
posted
0
Try using binary InputStream and OutputStream, not character Writer and Reader. NOTE: wrong group, this should go to I/O and Streams