java - java中如何删除文件中的数字

标签 java text-mining

这是我的代码..帮我删除逗号之前的数字并打印这两个单词

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-

最佳答案

我可以为您提供步骤

  1. 用 , 分割字符串
  2. 然后迭代该字符串数组并用 - 分割它 3然后打印该数组,我认为这就是您所需要的。

关于java - java中如何删除文件中的数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26604601/

相关文章:

java - 如何在不支持 GUI 的 headless Linux 上运行 Java GUI 应用程序?

java - 使用 connection.createStatement().executeQuery(String query); 是否安全?

python - 删除python中的所有标点符号

algorithm - 将文本解析为数据模型

python - 从图像中提取文本

elasticsearch - 如何在 Elasticsearch 中从文本中获得分数相似标签的总和

java - 如何将绘图上的 x 和 y 坐标转换为 GUI 上的像素

java - Gson:序列化数组时删除多余的换行符

java - (Java) 使用 Java8 将 JSONObject 的 JSONArray 展平为 [[]]

python - 文本挖掘: Query search