簡體   English   中英

如何在引號之間輸出字符串(在控制台中)?

[英]How to output the string (in the console) between quotation marks?

我有一個文本文件,內容是:

"hello world"

我的目標是僅輸出:

hello world

我的問題是怎么做? 提前謝謝程序員!

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM