• Post Reply Bookmark Topic Watch Topic
  • New Topic

How To Download and Recreate GIF Images?  RSS feed

 
C Balajee
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try using binary InputStream and OutputStream, not character Writer and Reader.
NOTE: wrong group, this should go to I/O and Streams
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay, so I'll move it there....

-Nate
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!