我想为客户端和服务器建立套接字连接以显示文件列表。但是下面的代码不会从服务器获取任何输入或将输出提供给客户端。请帮忙。
服务器
package javaapplicationthread;
import java.net.ServerSocket;
import java.net.Socket;
import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.PrintWriter;
public class zs {
public static int reads,red;
public static void main(String[] args)
{
int flg=0;
try{while(true){
ServerSocket serverSocket = new ServerSocket(1312);
Socket clientSocket = serverSocket.accept();
BufferedReader bufferedReader;
PrintWriter outk=new PrintWriter(clientSocket.getOutputStream(),true);
bufferedReader = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
String inputLine = bufferedReader.readLine();
System.out.println("input is"+ inputLine);
outk.write("abc");
File inputFolder = new File(inputLine);
System.out.println("control is being sent to traverse");
traverse(inputFolder, "");
}
}
catch (IOException ex) {
System.out.println("my exception is"+ex)
System.out.println(leftIndent + parentNode.getName());
}
}}