Note: PhoneServer.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.
--------------------
是什么错误,怎么改?
多谢!

解决方案 »

  1.   

    PhoneServer.java 程序用了其所继承类的过时了的方法。
    最好把代码贴出来
      

  2.   

    代码中使用了不被推荐的方法(过时的)编译时用 
       javac -deprecation  类名.java就可以了建议改使用的组件的新方法!
      

  3.   

    //服务器端:PhoneServer.java/* PhoneServer.java */
    import java.net.*;
    import java.io.*;public class PhoneServer
    {
    static final int OutPort=7000;
    static final int InPort=7001; //服务方应用程序
    //创建InServer 和 OutServer 的实例
    public static void main(String args[]){
    OutServer outserver=new OutServer(OutPort);
    InServer inServer=new InServer(InPort);
    }
    }//OutServer 类创建一服务器socket用于向客户端写数据
    class OutServer implements Runnable
    {
    //ServerSocket实例
    ServerSocket server=null; //真正用于写数据的socket
    Socket socket=null;
     
        //用于写数据的PrintStream流
    PrintStream stream=null;
    int thePort; //用于等待socket接受的独立线程
    Thread thread;
    public OutServer(int port){
    thePort=port;
    thread=new Thread(this);
    thread.start();
    } //等待socket连接和向客户端写数据的线程
    public void run(){
    try{
    server=new ServerSocket(thePort);
    }
    catch(Exception e){
    System.out.println(e);
    System.exit(1);
    }
    while(true)
    {
    try{
    socket=server.accept();
    }
    catch(Exception e){
    System.out.println(e);
    System.exit(1);
    }
    try{
    stream=new PrintStream(socket.getOutputStream());
    }
    catch(Exception e){
    System.out.println(e);
    System.exit(1);
    }
    FileInputStream fs=null;
    try{
    fs=new FileInputStream("PhoneBook.txt");
    }
    catch(Exception e){
    System.out.println(e);
    System.exit(1);
    }
    DataInputStream ds=new DataInputStream(fs);
    while(true)
    {
    try{
    String s=ds.readLine();
    if(s==null) break;
    stream.println(s);
    }
    catch(IOException e){
    System.out.println(e);
    break;
    }
    }
        try{
    fs.close();
    socket.close();
    }
        catch(IOException e){
    System.out.println(e);
    }
    }
    }  //end run()
    } //end OutServer//InServer 类创建一服务器socket用于从客户端读数据
    class InServer implements Runnable{ //ServerSocket实例
    ServerSocket server=null; //真正用于读的socket
    Socket socket; //真正用于读数据的DataInputStream流
    DataInputStream stream=null;
    int thePort; //用于等待socket接受的独立线程
    Thread thread; //构造函数中启动线程
    public InServer(int port){
    thePort=port;
    thread=new Thread(this);
    thread.start();
    } //等待socket连接并从客户端读数据的线程
    public void run(){
    try{
    server=new ServerSocket(thePort);
    }
    catch(Exception e){
    System.out.println(e);
    System.exit(1);
    }
    while(true)
    {
    try{
    socket=server.accept();
    }
    catch(Exception e){
    System.out.println(e);
    System.exit(1);
    }
    try{
    stream=new DataInputStream(socket.getInputStream());
    }
    catch(Exception e)
    {
    System.out.println(e);
    System.exit(1);
    }
    FileOutputStream fs=null;
    try{
    fs=new FileOutputStream("PhoneBood.txt");
    }
    catch(Exception e){
    System.out.println(e);
    System.exit(1);
    }
    PrintStream ds=new PrintStream(fs);
    while(true)
    {
    try{
    String s=stream.readLine();
    if(s==null) break;
    ds.println(s);
    }
    catch(IOException e){
    System.out.println(e);
    break;
    }
    }
    try{
    fs.close();
    socket.close();
    }
    catch(IOException e)
    {
    System.out.println(e);
    }
    }
    }
    }
      

  4.   

    是java版本的问题吧!
    只会产生一些警告信息,但还是可以用的!

    javac -deprecation youclass.java编译看看...
      

  5.   

    不如再帮我编译上面的代码,
    为什么老是出错提示:  Unable to open socket到底错在哪里?