求教个问题 求高手解答 谢谢 可以用一个正则去匹配,只要find()为true,取出group()就是你想要的数据了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用substring啊,把内容读进来,然后放到String中,然后截取,截取完后在放到另一个文件中 提供读取和写入文件的代码public static String readFile(String path) { String str = ""; File file = new File(path); BufferedReader reader = null; try { reader = new BufferedReader(new FileReader(file)); String tempString = null; String br= System.getProperty("line.separator"); while ((tempString = reader.readLine()) != null) { // 这里可以去判断下楼主自己写 //............ str = str+ tempString+br; } reader.close(); } catch (IOException e) { e.printStackTrace(); } finally { if (reader != null) { try { reader.close(); } catch (IOException e1) { } } } return str; } public static void writeToFile(String filePath, String sets) throws IOException { FileWriter fw = new FileWriter(filePath); PrintWriter out = new PrintWriter(fw); out.write(sets); out.println(); fw.close(); out.close(); } 同步锁的问题 如何使用jmf框架,在视频文件的第n帧合并一个音频文件,成一个新文件 有谁知道这是为什么?? 嵌在网页中的日历控件该如何写 求助.用什么方法才能将一个JRadioButton加入到JTable的某一格入面? 求教:关于JAVA的学习 有关编译文件的大小 关于paint(),repaint(),update()的关系? 计算sin360 怎样把变量代进SQL语句 Class<T>与T之间的区别与联系 三代重载,怎样调用第一代?
{
String str = "";
File file = new File(path);
BufferedReader reader = null;
try {
reader = new BufferedReader(new FileReader(file));
String tempString = null;
String br= System.getProperty("line.separator");
while ((tempString = reader.readLine()) != null) {
// 这里可以去判断下楼主自己写
//............
str = str+ tempString+br;
}
reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}
return str;
}
public static void writeToFile(String filePath, String sets) throws IOException {
FileWriter fw = new FileWriter(filePath);
PrintWriter out = new PrintWriter(fw);
out.write(sets);
out.println();
fw.close();
out.close();
}