我通过利用联合援助小组创建电子邮件客户服务器,但已经实施以下措施,但去了。
我正试图编制一个目录,并编制投入和产出流程。 我们请求用户,呼吁采用适当的方法(doSend或 doRead),关闭链接,然后询问用户是否希望再读/修改。
Email.java:
import java.io.*;
import java.net.*;
import java.util.*;
public class Email {
private static InetAddress host;
private static final int PORT = 21;
private static String name;
private static Scanner networkInput, userEntry;
private static PrintWriter networkOutput;
public static void main(String[] args) throws IOException {
try {
host = InetAddress.getLocalHost();
} catch (UnknownHostException uhEx) {
System.out.println("Host ID not found!");
System.exit(1);
}
userEntry = new Scanner(System.in);
do {
System.out.print("
Enter name ( Mike or Jack ): ");
name = userEntry.nextLine();
} while (!name.equals("Mike") && !name.equals("Jack"));
talkToServer();
}
private static void talkToServer() throws IOException {
String option, message, response;
do {
/*******************************************************
* I am trying to cREATE A SOCKET and SET UP the INPUT and the OUTPUT
* STREAMS. We Take USER S REQUEST, CALL UP THE APPROPRIATE METHOD
* (doSend or doRead), CLOSE THE LINK AND THEN ASK IF USER WANTS TO DO
* ANOTHER READ/SEND.
*******************************************************/
} while (!option.equals("n"));
}
private static void doSend() {
System.out.println("
Enter 1-line message: ");
String message = userEntry.nextLine();
networkOutput.println(name);
networkOutput.println("send");
networkOutput.println(message);
}
private static void doRead() throws IOException {
/*********************************
* I am trying to full the read method
*********************************/
}
}