Apoorva
Apoorva

Reputation: 1

How to delete a line spacing in csv file using java

Link<String> s = new ArrayList();
s = func();//this function returns a list of strings each of which will be in the //form of CREATE,i,j,k 

FileWriter ff = new FileWriter(fname,false);
for(String d:s)
{
ff.append(d);
}

When I used the above code Each string(i.e, record like CREATE,i,j,k is not placed in new line But when i use

ff.append(d+"\n")

I am getting a line spaccing between each line. So how to remove the line spacing or how to insert each record into new line without any line spacing

Upvotes: 0

Views: 140

Answers (1)

Uli
Uli

Reputation: 1500

Link<String> s = new ArrayList();
s = func();//this function returns a list of strings each of which will be in the //form of CREATE,i,j,k 

try (PrintWriter ff = new PrintWriter(new FileWriter(fname,false));)
{
  for(String d:s)
  {
      // print without line feed
      ff.print(d);
      // print with line feed
      ff.println(d);
  }
}

Upvotes: 1

Related Questions