关于将java中按行读取到的内容存储到一个字符串数组中的问题
有这样一个文件:
,
。
!
啊
哦
好的
.
.
.
等等,其中一个字符串占据一行,在txt文件中存储着,总共有535行,我下面按行读取,并把它放到数组String [] stopWordList中,出现了stopWordList[i]=null这种情况,大家帮帮我,看我的问题在哪里?
代码如下:
//读取文件
File input_data1=new File("D:/workspace/Percent1/Stopwords.txt");
FileReader fr1=new FileReader(input_data1);
BufferedReader br1=new BufferedReader(fr1);
String line1=null;
int i=0;
String [] stopWordList=new String[534];
while((line1=br1.readLine())!=null){
stopWordList[i]=line1;
i++;
line1 = br1.readLine();
System.out.println(stopWordList[i]);
}
br1.close();