一个TXT文件有3行,我读取第一行,指针就指向了第2行,所以我一输出就把第2行改了,我希望改的是第1行。
用seek() 我不知道中间的参数是多少可以退回第1行 seek(getFilePointer()- n) n 应该怎么算??;
另writeBytes 无法输出中文import java.io.*;
public class Hello {
public static void main(String[] args)
{
String str = new String();
try{
RandomAccessFile read = new RandomAccessFile("aaa.txt","rw");
str = read.readLine();
System.out.println(str);
read.writeBytes("aaaaa");
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
用seek() 我不知道中间的参数是多少可以退回第1行 seek(getFilePointer()- n) n 应该怎么算??;
另writeBytes 无法输出中文import java.io.*;
public class Hello {
public static void main(String[] args)
{
String str = new String();
try{
RandomAccessFile read = new RandomAccessFile("aaa.txt","rw");
str = read.readLine();
System.out.println(str);
read.writeBytes("aaaaa");
}
catch(FileNotFoundException e)
{
e.printStackTrace();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}
解决方案 »
- 请教关于多线程编程的问题,为何第二个线程无法开始执行
- myeclipse debug使用文章推荐下,谢谢
- 关于scanner读写系统输入的问题
- jeditorPane编辑的问题
- JAVA怎么获取他安装的路径
- 使用JNDI访问LDAP服务器区分大小写吗
- getRuntime()有什么用?
- 在Web环境下SQL Server存储过程返回结果集如果需要滚动就出错:Error setting up static cursor cache。而在普通应用中中正常
- 请问那位大哥大姐有关于JAVA语言实现的资料
- to:那位大侠可以提供关于用JAVA实现FTP的客户端程序,
- JSP小问题
- 如何,通过java串口编程来读写IC\ID卡的数据呀
怎么办啊