2
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 whole set of strings containing the occurrence name=
an arraylist of objects. After its storage, I will 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();
within the arraylist of objects was stored this (I had it printed 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 is this: As I look for the string name, then as I do to remove all its previous and later contents from the second quote, for example:
String pegaValorName = "<td><input type=\"radio\" name=\"pg4\" value=\"NÃO\" /></td>";
to pegaValorName
become only: pg4
And php where your problem is?
– rray
it is.. I removed php from tags
– Daniel Omine
I have a huge form in php (I have 40 forms to develop, the number of questions goes up to the number 100 and the nomenclature varies a lot), I’m making a code to make my life easier when creating the database (with create table). the idea is to read index.php (for now I’m doing it in .txt), take all name="something" and generate create table automatically. If there is another way to implement this, whether in java, php or another language, it would be open for help. But I accepted the modification.
– Jose Maximilian
Have you ever seen a library called
Jsoup
?– Renan Gomes