


String jsonScript = "constant header of json content" JsonFile = new BufferedWriter(new FileWriter("converted.txt"))

import java.io.BufferedReader ĬsvFile = new BufferedReader(new FileReader("DataTextCsv.csv")) See the following, you had your close methods in the wrong location. I'm conscious that it would be simpler to use more specific libraries, but as I'm new with Java, I wasn't able to find the right package to download and install The application can correctly read the first line of the csv file but can not continue till the end and I continuously get this error (even if I try to set all my csv data in one line: Exception in thread "main" java.io.IOException: Stream closedĪt java.io.BufferedReader.ensureOpen(Unknown Source)Īt java.io.BufferedReader.readLine(Unknown Source)Īt CSVConverter.main(CSVConverter.java:17) JsonScript=jsonScript.substring(0,jsonScript.length()-2) String jsonScript="constant header of json content" Here is a portion of my code: BufferedReader csvFile= new BufferedReader(new FileReader("DataTextCsv.csv")) īufferedWriter jsonFile=new BufferedWriter(new FileWriter("converted.txt")) I chose to simplify by using a classic method with BufferedReader and BufferedWriter. I have the naming of the fields static here, but you could use code to set the headers dynamically: for(var j=0 j
