Java 如何在引号之间输出字符串(在控制台中)?
我有一个文本文件,内容如下:Java 如何在引号之间输出字符串(在控制台中)?,java,string,Java,String,我有一个文本文件,内容如下: "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 File
"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
通过编程。使用
replaceAll
string.replace(“\”,”)
这仍然是一个不明确的要求。字符串是否可以包含其他双引号,如果是,应该如何处理它们。同样的想法可以是字符串前后的文件中有空白字符,以及应该如何处理。无论如何,你应该表现出诚实的尝试。这怎么可能被否决?谢谢Jay!非常感谢。