This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Sockets and Internet Protocols and the fly likes downloading files using sockets Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Reply Bookmark "downloading files using sockets" Watch "downloading files using sockets" New topic
Author

downloading files using sockets

Alessandro Brawerman
Greenhorn

Joined: Sep 22, 2003
Posts: 22
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
Marshal

Joined: Jul 08, 2003
Posts: 24057
    
  13

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.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: downloading files using sockets
 
Similar Threads
FTP Client
The question about generating RTF files using Java
Authenticate using BASE64Encoder
Doubt in Sockets!!
RMI and other threads writing/reading from sockets