求助,从html中提取一段内容,保存到文本中(初学者) 很简单,但是就是不会弄,读入一个slide.xml的文件,其中只要是<a:t> </a:t>都需要放到新的文本文件中。。多谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 参考下这个http://topic.csdn.net/t/20050418/18/3946904.html 这个做的 凑合用吧!!import java.io.BufferedReader;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.FileReader;import java.io.IOException;import java.util.regex.Matcher;import java.util.regex.Pattern;public class html { /** * @param args */ public static void main(String[] args) { String sssss = html.getiwant(); html.search(sssss); } private static void search(String ss) { String regex = "<a:t>(.+?)</a:t>"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(ss); while (matcher.find()) { System.out.println(matcher.group(1).trim()); try { FileOutputStream f = new FileOutputStream("E:/kk.txt", true); f.write((matcher.group(1)).getBytes()); f.close(); } catch (Exception e) { e.printStackTrace(); } } } public static String getiwant(){ String iwant = ""; try { BufferedReader buf = new BufferedReader(new FileReader( "E:\\temp\\aa.txt")); String line = ""; try { while ((line = buf.readLine()) != null) { iwant =iwant+line; } } catch (IOException e) { e.printStackTrace(); } } catch (FileNotFoundException e) { e.printStackTrace(); } System.out.println(iwant); return iwant; }}你要读入的 文件名 换换想把文件 输入 到哪里,叫什么名字都可以换 java字体设置 初级java怎么打印数组的值不是内存地址 循环录入Java课的学生成绩,统计分数大于等于 80分的学生比例 pdb文件解析 关于struts取数据 在广州普通Java程序员大概多少钱/月? JAVA开门遇到菜鸟级别问题……找不到JAVA.LANG 我的web页中使用了ActiveX控件,在Linux下能正确浏览吗?如果不可以怎样才能做到和平台无关呢? 新手求助!!!!!!拜托拜托 ?JAVA的问题 【求助】有关BufferesStream流中 读写是否需要刷新缓冲区的问题 关于mysql表名的大小写问题,很雷人,很黄,很暴力.
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;public class html {
/**
* @param args
*/
public static void main(String[] args) {
String sssss = html.getiwant();
html.search(sssss);
}
private static void search(String ss) {
String regex = "<a:t>(.+?)</a:t>";
Pattern pattern = Pattern.compile(regex);
Matcher matcher = pattern.matcher(ss);
while (matcher.find()) {
System.out.println(matcher.group(1).trim());
try {
FileOutputStream f = new FileOutputStream("E:/kk.txt", true);
f.write((matcher.group(1)).getBytes());
f.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
public static String getiwant(){
String iwant = "";
try {
BufferedReader buf = new BufferedReader(new FileReader(
"E:\\temp\\aa.txt"));
String line = "";
try {
while ((line = buf.readLine()) != null) {
iwant =iwant+line;
}
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
System.out.println(iwant);
return iwant;
}}你要读入的 文件名 换换
想把文件 输入 到哪里,叫什么名字都可以换