如何用telnet屏幕的显示保存到数据库? telnetjavasql server 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用程序?把console上得文字记录到文本中,读文本直接插入一个字段得了。不过我想不出来有什么作用 我已经能实现telnet了,但是就是不知道如何将屏幕的信息保存到数据库中。求解。 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); } } 现在我屏幕可以输出是可以了,但是要保存到数据库,有点麻烦。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; } ireport导出EXCEL一个很重要的小问题! 用java如何做放大镜 如何模拟<发短信>服务器?? servlet的问题 请教javaEE入门问题 一个不太留意的基础问题.现在才知道自己的基础差啊. jsp中的汉字到了action中成为乱码 专科生怎么这么难就业????? 汉字字符集的问题?? springboot Bean '' of type [] is not eligible for getting processed by all Eclipse 导入MyEclipse web 项目(求指导) Servlet与JSP核心编程会不会过时了
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);
}
}
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;
}