我的编辑文本是否有可能在第二行开始输入?假设第一行是“输入”。那可能吗?如果是这样,怎么做?
这是我正在谈论的代码。你能找到一个解决方案,为什么它一直不读第一行。我的解决方案是默认将第一行设为“输入”。或者你可以再找一个?
public class TestTCP
{
private static final int PORT = 1475;
private static ServerSocket serverSocket;
private static Socket clientSocket;
private static InputStreamReader inputStreamReader;
private static BufferedReader bufferedReader;
private static String message;
private static String multiple;
public static void main(String[] args)
{
try
{
serverSocket = new ServerSocket(PORT, 0, InetAddress.getLocalHost());
System.out.println("IP: " + serverSocket.getInetAddress() + " Port: " + serverSocket.getLocalPort());
} catch (IOException e)
{
System.out.println("Could not listen on port: 1447");
}
System.out.println("Server started. Listening to the port 1447");
while (true)
{
try
{{
clientSocket = serverSocket.accept(); // accept the client connection
inputStreamReader = new InputStreamReader(clientSocket.getInputStream());
bufferedReader = new BufferedReader(inputStreamReader); // get the client message
message = bufferedReader.readLine();
while ((message = bufferedReader.readLine()) != null) {
System.out.println("Message from Table 1: " + message);}
inputStreamReader.close();
clientSocket.close();}
} catch (IOException ex)
{
ex.printStackTrace();
System.out.println("Problem in message reading");
}
finally {
try {
if (bufferedReader != null)bufferedReader.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}}