0

I want to write comma separated data in CSV file. Writing http request response in it.

Following is the code-

FileWriter fw = new FileWriter(Constants.LOGGING_FILE_PATH, true);
fw.write(currTime + ","+ responseBody);
fw.write(System.getProperty( "line.separator" ));
fw.flush();
fw.close();

Now problem is response is multiline, So when data is shown in Excel it messed up. I have attached screen shot. Can I have all data in one cell. Like ALT+ENTER.enter image description here

5
  • Try this code : CSVWriter writer = null; try { writer = new CSVWriter(new FileWriter("/sdcard/myfile.csv"), ','); String[] entries = "first#second#third".split("#"); // array of your values writer.writeNext(entries); writer.close(); } catch (IOException e) { //error } Commented Jul 29, 2016 at 7:19
  • Watch this link : stackoverflow.com/questions/4632501/… Commented Jul 29, 2016 at 7:19
  • You can get list of data in one string and set it in the cell. Like : viralpatel.net/blogs/java-read-write-csv-file Commented Jul 29, 2016 at 7:23
  • mayurvpatel110, not working. Its saving data with hash. Commented Jul 29, 2016 at 8:01
  • And I want to use FIleWriter without using CSV lib. Commented Jul 29, 2016 at 8:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.