如何在引号之间输出字符串(在控制台中)?

时间:2018-03-07 12:13:44

标签: java string

我有一个文本文件,内容是:

"hello world"

我的目标是仅输出:

hello world

我的问题是怎么做?提前感谢程序员!

1 个答案:

答案 0 :(得分:2)

import java.io.*;
class Main {
  public static void main(String[] args)throws Exception
  {
  File file = new File("input.txt");
  BufferedReader br = new BufferedReader(new FileReader(file));
  String st;
  while ((st = br.readLine()) != null)
    System.out.println(st.replace("\"", ""));
  }
}
  

input.txt

     

“你好世界”

输出:

hello world