test content.txt
<td><input type="radio" name="pg1" value="SIM" /></td>
<td><input type="radio" name="pg1" value="NÃO" /></td>
<td><input type="radio" name="pg2" value="SIM" /></td>
<td><input type="radio" name="pg2" value="NÃO" /></td>
<td><input type="radio" name="pg3" value="SIM" /></td>
<td><input type="radio" name="pg3" value="NÃO" /></td>
<td><input type="radio" name="pg4" value="SIM" /></td>
<td><input type="radio" name="pg4" value="NÃO" /></td>
In this program it saves the entire set of strings containing the name=
occurrence within an arraylist of objects. After its storage, I'll do the processing of each string.
Reader lerArquivo = new FileReader("teste.txt");
BufferedReader br2 = new BufferedReader(lerArquivo);
ArrayList<Perguntas> valores = new ArrayList<>();
String linha;
String delims = "\"";
while ((linha = br2.readLine()) != null) {
if (linha.contains("name=")) {
Perguntas form = new Perguntas();
form.setNomeDaPergunta(linha);
valores.add(form);
}
}
System.out.println("valores.size()-> " + valores.size());
//fazendo o tratamento das strings
for (int i = 0; i < valores.size(); i++) {
System.out.println("-> " + valores.get(i).getNomeDaPergunta());
}
lerArquivo.close();
br2.close();
Inside the object arraylist was stored (I had to print what I had inside the arraylist of objects)
<td><input type="radio" name="pg1" value="SIM" /></td>
<td><input type="radio" name="pg1" value="NÃO" /></td>
<td><input type="radio" name="pg2" value="SIM" /></td>
<td><input type="radio" name="pg2" value="NÃO" /></td>
<td><input type="radio" name="pg3" value="SIM" /></td>
<td><input type="radio" name="pg3" value="NÃO" /></td>
<td><input type="radio" name="pg4" value="SIM" /></td>
<td><input type="radio" name="pg4" value="NÃO" /></td>
my question: How do I search for the string name, then how do I remove all of its contents before and after the second quotation mark, for example:
String pegaValorName = "<td><input type=\"radio\" name=\"pg4\" value=\"NÃO\" /></td>";
a pegaValorName
becomes only: pg4