关于将java中按行读取到的内容存储到一个字符串数组中的问题

sunboy01 sunboy01 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
有这样一个文件:
,
。
!
啊
哦
好的
.
.
.
等等,其中一个字符串占据一行,在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();
...全文
评论 10
收藏 已收藏
分享
返回顶部
sunboy01
Eclipse 58,439 成员 49,457 内容