我想用JAVA实现提取某个文本文件中的某行数据,
如提取出“OS details: Microsoft Windows XP SP2”,请问高手这个该怎么实现呢
文本内容如下# Nmap 4.53 scan initiated Thu Nov 06 08:52:28 2008 as: nmap -sS -O -v -oN baohui 192.168.6.21
Initiating OS detection (try #1) against 192.168.6.21
Interesting ports on 192.168.6.21:
Not shown: 1709 filtered ports
PORT STATE SERVICE
80/tcp open http
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
3389/tcp open ms-term-serv
MAC Address: 00:1B:B9:85:FE:95 (Elitegroup Computer System Co.)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Microsoft Windows XP
OS details: Microsoft Windows XP SP2
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=260 (Good luck!)
IP ID Sequence Generation: IncrementalRead data files from: E:\nmap-4.53
OS detection performed. Please report any incorrect results at http://insecure.org/nmap/submit/ .
# Nmap done at Thu Nov 06 08:52:38 2008 -- 1 IP address (1 host up) scanned in 10.391 seconds
如提取出“OS details: Microsoft Windows XP SP2”,请问高手这个该怎么实现呢
文本内容如下# Nmap 4.53 scan initiated Thu Nov 06 08:52:28 2008 as: nmap -sS -O -v -oN baohui 192.168.6.21
Initiating OS detection (try #1) against 192.168.6.21
Interesting ports on 192.168.6.21:
Not shown: 1709 filtered ports
PORT STATE SERVICE
80/tcp open http
139/tcp open netbios-ssn
443/tcp open https
445/tcp open microsoft-ds
3389/tcp open ms-term-serv
MAC Address: 00:1B:B9:85:FE:95 (Elitegroup Computer System Co.)
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: general purpose
Running: Microsoft Windows XP
OS details: Microsoft Windows XP SP2
Network Distance: 1 hop
TCP Sequence Prediction: Difficulty=260 (Good luck!)
IP ID Sequence Generation: IncrementalRead data files from: E:\nmap-4.53
OS detection performed. Please report any incorrect results at http://insecure.org/nmap/submit/ .
# Nmap done at Thu Nov 06 08:52:38 2008 -- 1 IP address (1 host up) scanned in 10.391 seconds
解决方案 »
- eclipse中怎样添加自定义的包
- 急!!急!!!!!hibernate 无法生成表???
- 类似于数字金字塔的题目,实在是不知道用嵌套循环怎么来写算法,急啊
- 如何用JBuilder中用可视化功能给JComboBox添加内容
- 怎样读懂Java源文件呢?
- 构造了一个取年龄的方法,结果确为0 ,众前辈快来指教
- swing中的问题
- Java中常量的问题:为什么10可以赋值给byte,short和int而没有编译错误!
- rmi调用server端方法出错
- 求助,很简单的。。。
- SWT 数据量很大,有什么优化的方法吗?介绍一下谢谢
- numIncre(“000099”) => “000100”,返回同闊度數字型字串,请教大家有什么更好的实现方法?
建议将文本修改为Properties格式的文件.名值对应.可以解决LZ的问题
FileReader ini = new FileReader(inipath);
BufferedReader iniparameter = new BufferedReader(ini);
iniparameter.skip(10);//跳过多少个字符
mdbUrl = iniparameter.readLine();
public class TTTT { public static String getString(String filename) throws IOException {
StringBuffer sb = new StringBuffer();
BufferedReader r = null; r = new BufferedReader(new InputStreamReader(new FileInputStream(filename), "utf-8"));
String s = null;
while ((s = r.readLine()) != null) {
if(s.startsWith("OS details:"))
break;
}
r.close();
return s;
} public static void main(String[] args) throws IOException {
String s = getString("tt.txt");
System.out.println(s); }
}