protected void executing(Properties prop) { Socket tClientSocket = null;
InputStream in = null;
OutputStream out = null;
int iread = 0;
byte[] bRequPkgBuf = new byte[1024];
StringBuffer sbRequPkg = new StringBuffer();
String strRequPkg = null;
try {
if (prop != null) {
//prop中得到的是serversocket.accept()返回的socket对象
tClientSocket = (Socket) prop.get("CLIENT_SOCKET");
out = tClientSocket.getOutputStream();
in = tClientSocket.getInputStream();
while (true) {
//读取请求报文信息
iread = in.read(bRequPkgBuf, 0, 1024);
System.out.println("iread =" + iread);
sbRequPkg.append(new String(bRequPkgBuf, 0, iread));
if (sbRequPkg.toString().indexOf(PKG_END) > -1) //收到结束符则退出.
break;
}
out.close();
in.close();
}
}
catch (Exception e) {
MiniLog.error(new Exception(), e);
e.printStackTrace();
}
finally {
try {
if (out != null)
out.close();
if (in != null)
in.close();
}
catch (Exception e) {
MiniLog.error(new Exception(), e);
e.printStackTrace();
}
try {
if (tClientSocket != null)
tClientSocket.close();
}
catch (Exception e) {
MiniLog.error(new Exception(), e);
e.printStackTrace();
} in = null;
out = null;
tClientSocket = null;
}
}
此行报错: sbRequPkg.append(new String(bRequPkgBuf, 0, iread));
但不知道是什么错,高手指教
InputStream in = null;
OutputStream out = null;
int iread = 0;
byte[] bRequPkgBuf = new byte[1024];
StringBuffer sbRequPkg = new StringBuffer();
String strRequPkg = null;
try {
if (prop != null) {
//prop中得到的是serversocket.accept()返回的socket对象
tClientSocket = (Socket) prop.get("CLIENT_SOCKET");
out = tClientSocket.getOutputStream();
in = tClientSocket.getInputStream();
while (true) {
//读取请求报文信息
iread = in.read(bRequPkgBuf, 0, 1024);
System.out.println("iread =" + iread);
sbRequPkg.append(new String(bRequPkgBuf, 0, iread));
if (sbRequPkg.toString().indexOf(PKG_END) > -1) //收到结束符则退出.
break;
}
out.close();
in.close();
}
}
catch (Exception e) {
MiniLog.error(new Exception(), e);
e.printStackTrace();
}
finally {
try {
if (out != null)
out.close();
if (in != null)
in.close();
}
catch (Exception e) {
MiniLog.error(new Exception(), e);
e.printStackTrace();
}
try {
if (tClientSocket != null)
tClientSocket.close();
}
catch (Exception e) {
MiniLog.error(new Exception(), e);
e.printStackTrace();
} in = null;
out = null;
tClientSocket = null;
}
}
此行报错: sbRequPkg.append(new String(bRequPkgBuf, 0, iread));
但不知道是什么错,高手指教
但不知道是什么错?
答:请将错误信息贴出来,就清楚了。