Pls help me. Thanks.
package com.codegym.task.task19.task1918;
/*
Introducing tags
*/
import java.io.*;
public class Solution {
static boolean debug = false;
public static void main(String[] args) throws IOException {
String file3 = ""; String pmm = "";
try {
//pmm = args[0];
pmm = "span";
}
catch(ArrayIndexOutOfBoundsException e) {
//System.out.println(e);
}
if(debug){
file3 = "C:\\file3.txt";
}else {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
file3 = reader.readLine();
reader.close();
}
BufferedReader reader2 = new BufferedReader(new FileReader(file3));
String str2 = "";
while (reader2.ready()) {
str2 += reader2.readLine();
}
reader2.close();
str2 = str2.replaceAll("\n", "");
str2 = str2.replaceAll("\r", "");
String startingTag = "<" + pmm;
String closingTag = "</" + pmm + ">";
String[] sp = str2.split(startingTag);
String bTag = "<b><" + pmm + ">";
String lTag = "</" + pmm + "></b>";
String contents = "";
String cts = "";
String word;
for (int i = 1; i < sp.length; i++) {
word = sp[i];
contents += startingTag + word;
if (word.contains(closingTag)) {
System.out.println(contents); cts = contents; contents ="";}
if (cts.contains(bTag)) {
String[] sp1 = cts.split(bTag);
String st2 = null;
for (String st1 : sp1) {
if (st1.contains(lTag)) {
int idx = st1.indexOf(lTag);
st2 = st1.substring(0,idx);
System.out.println(startingTag+">"+st2+closingTag); cts = "";
}
}
}
}
}
}