import java.io.*; public class WriteUTF8{ public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter File name : "); String str = in.readLine(); File file = new File(str); if(!file.exists()) { System.out.println("File does not exist"); System.exit(0); } else { try{ BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),"UTF8")); out.write("WelCome to RoseIndia.Net"); out.close(); System.out.println("Written Process Completed"); } catch(UnsupportedEncodingException ue){ System.out.println("Not supported : "); } catch(IOException e){ System.out.println(e.getMessage()); } } } }