Recently I've created a tool to get info from a website, and it works very good. I face a small problem, the result I want it to be line by line, it is line by line when there is a specific data but when this specific data are not there, the result is pasted in the same line ! for example :
WTY START WTY END SER.STRT SER.END
1 1 1 1
2 2 3 3
4 4 4
the number 3 must be in the next line. I tried a lot with it but seems there is something I'm blind to see it. My code is
for(Element ele : tableElements)
{
Elements theElements = ele.select("tr > th.pg2TableSectionTitle");
if (theElements != null && theElements.size() > 0) {
String tableTitle = theElements.get(0).text();
// Getting the required data from the tables
if (tableTitle.contains("General Machine Information:")) {
theElements = ele.select("td");
String contenent;
contenent = theElements.toString();
Scanner sr = new Scanner(contenent);
//System.out.println(contenent);
// Getting the model data
model = contenent.substring(53, 56);
// Getting the country data
if (contenent.contains("Country:")) {
country = sr.nextLine();
country = country.substring(20);
}
textArea_1.append(type + '\t' + model + '\t' + serial + '\t' + " " + country + " ");
}
**// my problem is here ----->**
// Getting the warranty data
if (tableTitle.equalsIgnoreCase("Warranty and Service Information:")) {
theElements = ele.select("td");
String dates;
dates = theElements.toString();
startDate = dates.substring(4,14);
endDate = dates.substring(24,34);
textArea_1.append(startDate + '\t' + endDate + '\t');
// if I add a line after the '\t' it will affect the next if statement, I mean that if there is a service pack data, it will be in a separate line.
}
// Getting the service pack data
if (tableTitle.equalsIgnoreCase("Upgrade Warranty and Service Information:")) {
theElements = ele.select("td");
String dates1 = theElements.toString();
startDate1 = dates1.substring(4,14);
endDate1 = dates1.substring(24,34);
textArea_1.append(startDate1 + '\t' + endDate1 + '\n');
// If I took out the '\n', the results will be in one line onle !!
}
}
}
Aucun commentaire:
Enregistrer un commentaire