reader1=new BufferedReader (new FileReader(path+"1\\"+file[i]));
while((line=reader1.readLine())!=null){
oldMap.put(line,"a");
System.out.println(line);
}
reader1.close();
while((line=reader1.readLine())!=null){
oldMap.put(line,"a");
System.out.println(line);
}
reader1.close();
假如是好像数据的话 可以换成DataInpuStream.
String htmPath="c:\\file.in";
RandomAccessFile fhtm=new RandomAccessFile(htmPath,"r");
long filePointer=0;
long length=fhtm.length();
while(filePointer<length)
{
Content=Content + fhtm.readLine();
filePointer=fhtm.getFilePointer();
}
fhtm.close();
比如说原来
String str = "I love you \n \n You love me??\n\n"现在我只是把"I love you \n \n You love me??\n\n"这些内容放在一个叫file.in的文件里,想要用BufferedReader, FileReader和readLine等打开这个文件,然后把这些字符全部放到str里,我试过上面的这些方法,好想都不是很好,请大家再帮帮忙,谢谢了!
public static void main(String[] args) throws IOException{
FileReader fr = new FileReader("C:/file.in");
int i = 0;
String str = "";
while((i = fr.read())!=-1)
str += (char)i;
fr.close();
System.out.println(str);
}
}
就是任何一个不知道名字的文件,应该怎么做哪? 是不是要用args[0]来表示这个文件?
怎样用FileReader来读取args[0]哪? 我试了很多种方法都不行,报错说" cannot resolve symbol".我是在Unix环境下编程的.
很急,请各位高手再麻烦一下,感激不尽!