[java]removing unwanted data from a file
hi,
i have made a program that downloads a file from an Internet sites in 2 chunks. I am sending request for first half of the total byte size of the file and then reading the Input Stream of the server socket byte by byte into a file.Same thing I do for the second chunk of bytes( I append to the same file). Now with each response from the server, a header comes with the byte chunk....................so in the file those headers are also written(two times, one for each request). E.g when i downloaded a .java file, I got the final file as
HTTP/1.0 206 Partial Content
Date: Sat, 23 Oct 2004 18:39:44 GMT
Server: Apache/2.0.49 (Fedora)
Last-Modified: Tue, 10 Sep 2002 09:55:10 GMT
Accept-Ranges: bytes
Content-Type: text/plain; charset=ISO-8859-1
Content-Range: bytes 0-864/1728
Content-Length: 865
Age: 51344
X-Cache: HIT from ernetproxy
Proxy-Connection: close
/**
* this prog. generates various features of cows.
*
* saurabh gupta
* 6th august 2k2
*/
public class cow
{
public static void main(String args[])
{walking_cow();
running_cow();
braking_cow();
apanight_cow();
}
public static void walking_cow()
{
System.out.println("* (__)");
System.out.println(" \\ (oo)");
System.out.println(" \\-------\\/");
System.out.println(" /| |\\");
System.out.println("//||------||\\\\");
System.out.println("\" \"\" \"\" \"");
System.out.println("cow walking");
System.out.println(" ");
}
public static void running_cow()
{
System.out.println(" (__)");
System.out.println(" (oo)");
System.out.println(" /-------\\/");
System.out.println(" / \\ /");
System.out.println("* \\\\--//");
Syste˙HTTP/1.0 206 Partial Content
Date: Sat, 23 Oct 2004 18:39:44 GMT
Server: Apache/2.0.49 (Fedora)
Last-Modified: Tue, 10 Sep 2002 09:55:10 GMT
Accept-Ranges: bytes
Content-Type: text/plain; charset=ISO-8859-1
Content-Range: bytes 865-1727/1728
Content-Length: 863
Age: 51347
X-Cache: HIT from ernetproxy
Proxy-Connection: close
m.out.println(" \" \"");
System.out.println(" cow running");
System.out.println(" ");
}
public static void braking_cow()
{
System.out.println(" (__)");
System.out.println(" (oo)");
System.out.println(" /----------\\/");
System.out.println(" / \\ \\");
System.out.println("* \\\\--------\\\\");
System.out.println(" \" \"");
System.out.println(" cow braking");
System.out.println(" ");
}
public static void apanight_cow()
{
System.out.println(" (__)");
System.out.println(" (--)");
System.out.println(" /----------\\/");
System.out.println(" /| ||");
System.out.println("* ||---------||");
System.out.println(" \"\" \"\"");
System.out.println("cow after pulling a night out");
}
}
You can see two headers, one at the start and one in between. Now how do i remove these headers from the file, or how do i check the header content to get written to the file when i am reading from the input stream of the socket.
please help....its urgent.........
-DJ
|