I am taking in a string from a website that looks along the lines of <HTML CODE HERE>Text I want to get and remove the brackets and the text within them, however, my end result is always null.
What I am trying is,
try {
String desc = null;
StringBuilder sb = new StringBuilder();
BufferedReader r = new BufferedReader(new InputStreamReader(in));
String line = null;
boolean codeBlock;
codeBlock = false;
line = "<HTMLCODEHERE>Text I want to get";
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! STARTING DESC: " + line);
while((line = r.readLine()) != null) {
if((line = r.readLine()) == "<") {
codeBlock = true;
}
if((line = r.readLine()) == ">") {
codeBlock = false;
}
if(!codeBlock) {
sb.append(line);
desc = sb.toString();
}
}
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ENDING DESC: " + desc);
holder.txtContent.setText(desc);
} catch (IOException e) {
e.printStackTrace();
}
<or>?