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
請問問題在那裡?
怎麼改呢?