在写一个词法分析题,为了能控制文件游标,我使用了RandomAccessFile类。
代码如下
public static void main(String[] args) throws IOException {
File readFile = new File("e:/text.txt");
File writeFile = new File("e:/text2.txt");
RandomAccessFile Read = new RandomAccessFile("e:/text.txt", "rwd");
RandomAccessFile Write = new RandomAccessFile("e:/text2.txt", "rwd");
Write.write(Read.read());
doFun(Read, Write);
Read.close();
Write.close();
return;
}dofun是我另外写的一个函数,把Read和Write作为空值传入,debug的时候发现dofun里面这两个参数出现空指针异常,请达人帮忙结识,在线等答案。
多谢
代码如下
public static void main(String[] args) throws IOException {
File readFile = new File("e:/text.txt");
File writeFile = new File("e:/text2.txt");
RandomAccessFile Read = new RandomAccessFile("e:/text.txt", "rwd");
RandomAccessFile Write = new RandomAccessFile("e:/text2.txt", "rwd");
Write.write(Read.read());
doFun(Read, Write);
Read.close();
Write.close();
return;
}dofun是我另外写的一个函数,把Read和Write作为空值传入,debug的时候发现dofun里面这两个参数出现空指针异常,请达人帮忙结识,在线等答案。
多谢
RandomAccessFile Write = new RandomAccessFile("e:/text2.txt", "rwd");这个时候Read和write不是已经有值了么?
为什么叫空值传入了?
达人给讲讲...我java基础模糊了开始
有什么用?
所以应该是dofun函数出问题了。还有在JAVA中没有提供引用转入的功能。好像所有的参数全是按值传入的...
不知道问题是不是出在这...