M
mike
outSocket.getInputStream transmit back a "http header" and a HTML
entity,
in the following java code,i plan to save the "http header" in the
file
"tidyHTTPHeader.txt" and save the HTML entity in the file
"tidytemp.html"
i run the code , i find that i get the 2 file
tidyHTTPHeader.txt,and
tidytemp.html.but strange to say,my code cannot run to the line
:System.out.println("end while");seems that the program cannot run
out
of the while loop
any suggestions?...
thanks a lot
----------------------------------------------------------------------------
InputStream in = outSocket.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader
((InputStream) in));
FileWriter fw = new FileWriter("tidytemp.html");
FileWriter fwHTTPHeader= new FileWriter("tidyHTTPHeader.txt");
boolean headerflag=true;
boolean HTMLflag=false;
String line;
while((line=br.readLine()) != null) {
// line=br.readLine();
if(line.length()!=0 && headerflag==true && HTMLflag==false){
fwHTTPHeader.write(line+"\r\n");
}
else if(line.length()==0 && headerflag==true && HTMLflag==false){
fwHTTPHeader.write(line+"\r\n");
headerflag=false;
HTMLflag=true;
fwHTTPHeader.close();
}
else if(line.length()==0 && headerflag==false && HTMLflag==true){
fw.write(line+"\r\n");
}
else {
fw.write(line+"\r\n");
}
System.out.println("test");
}
System.out.println("end while");
entity,
in the following java code,i plan to save the "http header" in the
file
"tidyHTTPHeader.txt" and save the HTML entity in the file
"tidytemp.html"
i run the code , i find that i get the 2 file
tidyHTTPHeader.txt,and
tidytemp.html.but strange to say,my code cannot run to the line
:System.out.println("end while");seems that the program cannot run
out
of the while loop
any suggestions?...
thanks a lot
----------------------------------------------------------------------------
InputStream in = outSocket.getInputStream();
BufferedReader br = new BufferedReader(new InputStreamReader
((InputStream) in));
FileWriter fw = new FileWriter("tidytemp.html");
FileWriter fwHTTPHeader= new FileWriter("tidyHTTPHeader.txt");
boolean headerflag=true;
boolean HTMLflag=false;
String line;
while((line=br.readLine()) != null) {
// line=br.readLine();
if(line.length()!=0 && headerflag==true && HTMLflag==false){
fwHTTPHeader.write(line+"\r\n");
}
else if(line.length()==0 && headerflag==true && HTMLflag==false){
fwHTTPHeader.write(line+"\r\n");
headerflag=false;
HTMLflag=true;
fwHTTPHeader.close();
}
else if(line.length()==0 && headerflag==false && HTMLflag==true){
fw.write(line+"\r\n");
}
else {
fw.write(line+"\r\n");
}
System.out.println("test");
}
System.out.println("end while");