这是我的代码..帮我删除逗号之前的数字并打印这两个单词
for(int y=0;y<nso.length;y++)
{
File e=new File(nso[y]);
BufferedReader be=new BufferedReader(new FileReader(e));
String st,t;
while((st=be.readLine())!=null)
{
if(st.contains("ns"))
{
int offset=st.indexOf("(");
st=st.substring(offset+1, st.length()-3);
System.out.println(st);
ap.write(st);
ap.println("\n");
}
}
ap.close();
be.close();
该文件包含
phone-6, This
know-8, I
looking-5, you
phone-14, this-
graphics-2, has-
最佳答案
我可以为您提供步骤
- 用 , 分割字符串
- 然后迭代该字符串数组并用 - 分割它 3然后打印该数组,我认为这就是您所需要的。
关于java - java中如何删除文件中的数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26604601/