java 技術問題!!!!

tosun 2003-03-10 08:25:01
import java.io.*;
import java.net.*;
import java.util.*;


public class ServerThread extends Thread
{ //1
private Socket socket = null;

public ServerThread (Socket socket)
{//2
super ("ServerThread");
this.socket = socket;
}//2

public void run (){ //3

try{ //4
BufferedReader in = new BufferedReader (new InputStreamReader (socket.getInputStream ( ) ) );
PrintWriter out = new PrintWriter (socket.getOutputStream ( ),true);
String ClientInput;
while (true){//5

try {
ClientInput = in.readLine ( );
out.println(word_count(ClientInput));
if ( (ClientInput == null) || (word_count(ClientInput)!=3) ) //check validation of request
{//*
out.println("error request");
break;
}//*
if(ClientInput.startsWith("GET"))
ClientInput = ClientInput.substring(4);
else if( ClientInput.startsWith( "HEAD" ) )
ClientInput = ClientInput.substring(5);
else out.println("System does not support");
if( (ClientInput.endsWith("HTTP/1.0") ) || (ClientInput.endsWith("HTTP/1.1") ) )
ClientInput=ClientInput.substring ( 0,ClientInput.length ( ) -9 );
}
catch(IOException e)
{
e.printStackTrace();
}


out.println(ClientInput);
String w = ClientInput;
if ( w == null || w.equals("/") )
default_Page(out);

------------------------------------------------------------------------- ServerThread.java:46: variable ClientInput might not have been initialized
out.println(Clien
tInput);
^
1 error

請問問題在那裡?
怎麼改呢?


...全文
25 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
yashiro 2003-03-10
  • 打赏
  • 举报
回复
ClientInput 没有初始化!
String ClientInput;
-->
String ClientInput="";

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧