Java 打印有什么问题,它停在某个地方不加载打印
这是我的代码,用于删除中的所有内容。Java 打印有什么问题,它停在某个地方不加载打印,java,printing,Java,Printing,这是我的代码,用于删除中的所有内容。 public static void main (String [] args) throws FileNotFoundException{ Scanner console = new Scanner(System.in); Scanner Theinput = GetUserInput (console); while (Theinput.hasNextLine()){ String Input = Theinput.nextLi
public static void main (String [] args) throws FileNotFoundException{
Scanner console = new Scanner(System.in);
Scanner Theinput = GetUserInput (console);
while (Theinput.hasNextLine()){
String Input = Theinput.nextLine();
Scanner text = new Scanner(Input);
if (text.hasNext()){
String MyNewText = Input;
while(MyNewText.contains("<") || MyNewText.contains(">") ){
int Max = MyNewText.indexOf ( ">" );
int Min = MyNewText.indexOf ( "<" );
String Replacement = "";
String ToReplacement = MyNewText.substring (Min,Max+1);
MyNewText = MyNewText.replaceAll(ToReplacement,Replacement);
}
System.out.println (MyNewText);
}
else {
System.out.println();
}
}
}
publicstaticvoidmain(字符串[]args)抛出FileNotFoundException{
扫描仪控制台=新扫描仪(System.in);
扫描仪输入=GetUserInput(控制台);
while(input.hasNextLine()){
字符串输入=Input.nextLine();
扫描仪文本=新扫描仪(输入);
if(text.hasNext()){
字符串MyNewText=输入;
while(MyNewText.contains(“”){
int Max=MyNewText.indexOf(“>”);
int Min=MyNewText.indexOf(“String out=”基本HTML示例页“.replaceAll(“,”);
System.out.println(out);
您可以尝试使用正则表达式,但它无法处理以下内容
<a
href="http://google.com"
target="_blank"
>google</a>
也许你应该考虑使用解析器,例如,使用一个解析器。用一段时间来学习java命名约定:变量和方法应该从小写开始,然后是CAMELCASE。抱歉……我只是对java的新命名约定。我的代码不怎么工作,我认为代码应该做正确的事情。
String out = "<TITLE>Basic HTML Sample Page</TITLE>".replaceAll("</?[a-zA-Z0-9]+?>", "");
System.out.println(out);
<a
href="http://google.com"
target="_blank"
>google</a>