Answer to Question #253217 in Java | JSP | JSF for Tarurendra Kushwah

Question #253217

Write java program to read and write character using file.


1
Expert's answer
2021-10-22T06:36:26-0400
import java.io.*;
public class Main
{
	public static void main(String[] args) {
		try{    
           FileWriter out=new FileWriter("output.txt");    
           out.write("Hello world.");    
           out.close();    
          }
        catch(Exception e){
            System.out.println(e);
        } 
        
        try{    
            FileReader in=new FileReader("output.txt");    
            int i;    
            while((i=in.read())!=-1)    
              System.out.print((char)i);    
            in.close();   
        }
        catch(Exception e){
            System.out.println(e);
        } 
           
	}
}

Output





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS