Advertisement
Guest User

Untitled

a guest
Mar 26th, 2012
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. public static void ecriturefichier(String str) throws IOException {
  2.   String ch;
  3.   Scanner sc = new Scanner (System.in);
  4.   System.out.println("donner votre chaine de caractéres :");
  5.   ch=sc.nextLine();
  6.   PrintWriter pw = null;
  7.   try {
  8.     pw = new PrintWriter(new BufferedWriter(new FileWriter(str)));
  9.     do {
  10.       pw.println(ch);
  11.       ch=sc.nextLine();
  12.     } while(!(ch.equals("fin")));
  13.   } finally {
  14.     if (null != fw) fw.close();
  15.   }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement