Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

downloading files using sockets  RSS feed

 
Alessandro Brawerman
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I'm implementing an application that downloads some files via sockets. After the download I locally save the files. The problem is that every time it includes a header before the text and don't want that to happen. I'm using the following to get the input stream:
InputStream input = new BufferedInputStream(socket1.getInoutStream);
Is this the problem? How to get rid of the header in the local files?
Thanks,
Alessandro.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24215
37
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, I'm going to guess that your sockets are connected to a Web server, or some other Internet server that sends more than just the file back to you when you request a file. There are two things you might do. One is to parse the data from the sockets and remove the headers yourself. Another, far easier solution is to use URLConnection instead of raw sockets; it will remove the headers for you; e.g.,
like this.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!