BAEL-5755: remove comments

This commit is contained in:
Vladyslav Chernov 2023-10-20 15:17:36 -07:00
parent 0bb7a8db27
commit a16aa0ee61
1 changed files with 1 additions and 4 deletions

View File

@ -51,7 +51,6 @@ public class Xml2CsvExample {
try (InputStream in = Files.newInputStream(Paths.get(xmlFilePath)); BufferedWriter writer = new BufferedWriter(new FileWriter(csvFilePath))) { try (InputStream in = Files.newInputStream(Paths.get(xmlFilePath)); BufferedWriter writer = new BufferedWriter(new FileWriter(csvFilePath))) {
// Write header to CSV
writer.write("bookstore_id,book_id,category,title,author_id,author_name,price\n"); writer.write("bookstore_id,book_id,category,title,author_id,author_name,price\n");
XMLStreamReader reader = inputFactory.createXMLStreamReader(in); XMLStreamReader reader = inputFactory.createXMLStreamReader(in);
@ -67,7 +66,7 @@ public class Xml2CsvExample {
case XMLStreamConstants.START_ELEMENT: case XMLStreamConstants.START_ELEMENT:
currentElement = reader.getLocalName(); currentElement = reader.getLocalName();
if ("Bookstore".equals(currentElement)) { if ("Bookstore".equals(currentElement)) {
bookstoreInfo.setLength(0); // clear previous bookstore info bookstoreInfo.setLength(0);
bookstoreInfo.append(reader.getAttributeValue(null, "id")) bookstoreInfo.append(reader.getAttributeValue(null, "id"))
.append(","); .append(",");
} }
@ -94,12 +93,10 @@ public class Xml2CsvExample {
case XMLStreamConstants.END_ELEMENT: case XMLStreamConstants.END_ELEMENT:
if ("Book".equals(reader.getLocalName())) { if ("Book".equals(reader.getLocalName())) {
// remove the last comma and add a newline
csvRow.setLength(csvRow.length() - 1); csvRow.setLength(csvRow.length() - 1);
csvRow.append("\n"); csvRow.append("\n");
writer.write(csvRow.toString()); writer.write(csvRow.toString());
// Reset the StringBuilder for the next row
csvRow.setLength(0); csvRow.setLength(0);
} }
break; break;