解决方案 »

  1.   

    用程序?把console上得文字记录到文本中,读文本直接插入一个字段得了。不过我想不出来有什么作用
      

  2.   

    我已经能实现telnet了,但是就是不知道如何将屏幕的信息保存到数据库中。求解。
      

  3.   

    synchronized (this) {
    try {
    out.print(cmd);
    out.flush();
    System.out.println("发送: " + cmd); while ((readed = in.readLine()) != null) {
    System.out.println("接收: " + readed);
    readedsb =readedsb.append(readed+"/r/n");
    } } catch (SocketTimeoutException e) {
    System.out.println("接收: 超时!"); // 忽略该异常
    } catch (IOException e) {
    throw new TelnetException(e);
    }
    }
      

  4.   

    现在我屏幕可以输出是可以了,但是要保存到数据库,有点麻烦。public String readUntil(String pattern) {
            try {  
                char lastChar = pattern.charAt(pattern.length() - 1); 
                StringBuffer sb = new StringBuffer(); 
                char ch = (char)in.read(); 
                while (true) {  
                    sb.append(ch);
                    if (ch == lastChar) {  
                        if (sb.toString().endsWith(pattern)) { 
                         return sb.toString(); 
                        }
                    }
                    if(ch==(char)13)
                    {
                  SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");//设置日期格式
                     Date now = new Date(); 
                     String sysdate = df.format( now );
                     String st = sb.toString();
                     if(st.length()>0)
                     {
                      String st2=st;
                     }
                     System.out.println("+++++++"+st+"======"+sysdate);
                    }
                    ch = (char)in.read(); 
                }
            } catch (Exception e) {  
                e.printStackTrace();  
            }  
            return null;
        }