Untitled

mail@pastecode.io avatar
unknown
java
a month ago
698 B
0
Indexable
Never
import java.io.*;
import java.util.Scanner;
public class FileHandle
{
    public static void main(String[] args) 
    {
        try
        {
            File f = new File("test.txt");
            Scanner s = new Scanner(f)
            String con = " ";
            while(s.hasNextLine())
            	cons += s.nextLine();
            FileWriter fw = new FileWriter("nfile.txt");
            fw.write(con);
            fw.close();
            System.out.println("File Writter");
        }
        catch(IOException e)
        {
            System.out.println("file not found");
        }
        finally
        {
            System.out.println("file is successfully read");
        }
    }
    
}
Leave a Comment