English 中文(简体)
Java Sending Email “Client服务器”
原标题:Java Sending Email "Client Server"
  • 时间:2011-10-02 19:25:11
  •  标签:
  • java
  • eclipse

我通过利用联合援助小组创建电子邮件客户服务器,但已经实施以下措施,但去了。

我正试图编制一个目录,并编制投入和产出流程。 我们请求用户,呼吁采用适当的方法(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
       *********************************/
   }
}
问题回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签