java IO更新文件部分内容 请问下如何让一个流IO程序更新文件部分内容呢?好心朋友帮帮我哈!谢谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 RandomAccessFile reader = null;try {reader = new RandomAccessFile(filepath, "rw");String tmpString = null;int line = 1;reader.writeByte('@');while ((tmpString = reader.readLine()) != null) {System.out.println(tmpString);if(tmpString.length() > 0){if (tmpString.charAt(0) != '@') {reader.writeByte('@');} else {System.out.println("(line:" + line + ":"+ tmpString + ")");}}line++;}reader.close();} catch (IOException e) {e.printStackTrace();} finally {if (reader != null) {try {reader.close();} catch (IOException e1) {}}} 我刚接触java 该做些什么 我的老师都不能搞定。来看看什么问题 POI 操作word问题 关于属性验证的问题 形如\u00a5的unicode 无法正常显示 请问怎样将字符串转换成Date类型?在线等 事件处理-各位高手请进 对于出初学者来说,选择那些书比较好? 问个初级的问题,J2SE,J2EE,J2ME相互之间的差别是什么,希望在线的朋友给个提示 运行问题 笔试题求解!! 集合基础知识
try {reader = new RandomAccessFile(filepath, "rw");
String tmpString = null;
int line = 1;
reader.writeByte('@');
while ((tmpString = reader.readLine()) != null) {
System.out.println(tmpString);
if(tmpString.length() > 0){if (tmpString.charAt(0) != '@') {reader.writeByte('@');} else {
System.out.println("(line:" + line + ":"+ tmpString + ")");
}
}
line++;
}reader.close();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e1) {
}
}
}