Почему сервер не принимает ввод от клиента? В чем ошибка?
public class Client
{
public static void main(String[] args)
{
try(Socket client=new Socket("192.168.56.1",7000);
PrintWriter pw = new PrintWriter(client.getOutputStream(), true);
BufferedReader reader=new BufferedReader(new InputStreamReader(client.getInputStream())))
{
String Text;
System.out.println(reader.readLine());
Scanner sc=new Scanner(System.in);
Text = sc.nextLine();
pw.print(Text);
System.out.println(reader.readLine());
Text = sc.nextLine();
pw.print(Text);
} catch (IOException e)
{
e.printStackTrace();
}
}
}
public class Server
{
public static void main(String[] args)
{
try(ServerSocket serverSocket=new ServerSocket(7000))
{
System.out.println("Start");
try (Socket server = serverSocket.accept();
BufferedReader reader=new BufferedReader(new InputStreamReader(server.getInputStream()));
PrintWriter pw = new PrintWriter(server.getOutputStream(), true))
{
pw.println("Write text");
String terx = reader.readLine();
pw.println("Text "+terx);
String file;
file=reader.readLine();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}