答:将代码
Java code
try {
inStream = incoming.getInputStream();
outStream = incoming.getOutputStream();
in = new DataInputStream(inStream);
out = new DataOutputStream(outStream);
BufferedReader br = new BufferedReader(new InputStreamReader(inStream,\"UTF-8\"));
String line =\"\";
String templine = \"\";
String filedata = \"\";
int b = 0;
while(true){
//读取数据
try {
line = br.readLine();
} catch(IOException e){
break;
}
}
} catch (IOException e) {
try{
if (incoming != null)
incoming.close();
} catch(IOException ex){
ft.setError(ex.getMessage());
}
}
try{
if(in != null)
in.close();
if(out != null)
out.close();
if (incoming != null)
incoming.close();
} catch(IOException ex)
{
ft.setError(ex.getMessage());
}
}
}
改为:
Java code
try {
inStream = incoming.getInputStream();
outStream = incoming.getOutputStream();
in = new DataInputStream(inStream);
out = new DataOutputStream(outStream);
BufferedReader br = new BufferedReader(new InputStreamReader(inStream,\"UTF-8\"));
String line =null;
String templine = \"\";
String filedata = \"\";
int b = 0;
//读取数据
line = br.readLine();
while(line!=null)
{
//对line数据进行处理的代码在此
line = br.readLine(); //读下一个数据行
} //while
} catch (IOException e) {
ft.setError(e.getMessage());
}
finally{
try{
if (incoming != null)
incoming.close();
} catch(IOException ex){
ft.setError(ex.getMessage());
}
try{
if(in != null)
in.close();
if(out != null)
out.close();
if (incoming != null)
incoming.close();
} catch(IOException ex)
{
ft.setError(ex.getMessage());
}
}