Advertisement
zihadrizkyef

Argument Error

Apr 10th, 2016
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class FileRW {
  4.     public static void main(String[] args) {
  5.         writeF("namaFile.txt", "Pondok", "Programmer");
  6.     }
  7.     public static void writeF(String[] args) {
  8.         PrintWriter fw = null;
  9.         try{fw = new PrintWriter(args[0], "UTF-8");}
  10.         catch(FileNotFoundException errorText) {System.out.println("ada error : "+errorText);}
  11.         catch(UnsupportedEncodingException errorText) {System.out.println("ada error : "+errorText);}
  12.         for(int i=1 ; i<=args.length ; i++){
  13.             fw.println(args[i]);
  14.         }
  15.         fw.close();
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement