Advertisement
Guest User

Untitled

a guest
Feb 19th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class CSVWriter {
  5.  
  6.   public static void writeDataLineByLine(String filePath) {
  7.     // first create file object for file placed at location
  8.     // specified by filepath
  9.     File file = new File(filePath);
  10.     try {
  11.       // create FileWriter object with file as parameter
  12.       FileWriter writer = new FileWriter(file);
  13.  
  14.    
  15.  
  16.       // closing writer connection
  17.       writer.close();
  18.     } catch (IOException e) {
  19.       // TODO Auto-generated catch block
  20.       e.printStackTrace();
  21.     }
  22.   }
  23.  
  24.   public void writePersonal(String filePath, String value) {
  25.     // first create file object for file placed at location
  26.     // specified by filepath
  27.  
  28.     File file = new File(filePath);
  29.     String comma = ",";
  30.     try {
  31.       // create FileWriter object with file as parameter
  32.       FileWriter writer = new FileWriter(file, true);
  33.       writer.append("','");
  34.       writer.append(value + ", ");
  35.       // writer.write(str);
  36.       writer.flush();
  37.       writer.close();
  38.     } catch (IOException e) {
  39.       // TODO Auto-generated catch block
  40.       e.printStackTrace();
  41.     }
  42.   }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement