Advertisement
Guest User

WriteFile

a guest
Dec 5th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1.  
  2. package concerthallbookingsystem;
  3.  
  4. import java.io.FileWriter;
  5. import java.io.PrintWriter;
  6. import java.io.IOException;
  7.  
  8.  
  9. public class WriteFile
  10. {
  11.     private String path;
  12.     private boolean append_to_file = false;
  13.    
  14.    
  15.     public WriteFile(String file_path)
  16.     {
  17.         path = file_path;
  18.        
  19.     }
  20.    
  21.     public WriteFile(String file_path, boolean append_value)
  22.     {
  23.         path = file_path;
  24.         append_to_file = append_value;
  25.                
  26.     }
  27.    
  28.     public void writeToFile(String textLine) throws IOException
  29.     {
  30.         FileWriter write = new FileWriter(path, append_to_file);
  31.         PrintWriter print_line = new PrintWriter(write);
  32.         print_line.printf("%s" + "%n", textLine);
  33.         print_line.close();
  34.     }
  35.    
  36.    
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement