Advertisement
FahimFaisal

Write

Feb 23rd, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package lab6_fileReadWrite;
  7.  
  8. import java.io.FileWriter;
  9. import java.io.IOException;
  10. import java.io.*;
  11.  
  12. /**
  13.  *
  14.  * @author acer
  15.  */
  16. public class fileWrite {
  17.     public static void main(String[] args) {
  18.         try {
  19.            
  20.             FileWriter fw=new FileWriter("C:\\Users\\acer\\Desktop\\new.txt");
  21.             PrintWriter pw=new PrintWriter(fw);
  22.            
  23.             pw.println("course1 : 10 credits");
  24.             pw.println("course2 : 13 credits");
  25.             pw.println("course3 : 32 credits");
  26.            
  27.             pw.close();
  28.            
  29.         } catch (Exception ex) {
  30.             ex.printStackTrace();
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement