Untitled
unknown
java
3 years ago
1.0 kB
7
Indexable
import java.io.*; import java.util.Scanner; public class fileAshoTumi { public static void main(String args[]) { try{ System.out.println("File Write now!!!"); System.out.println("Enter Your input: "); FileWriter f =new FileWriter("D:\\Tamima.txt"); Scanner scan = new Scanner(System.in); String data = scan.nextLine(); f.write(data); f.close(); //System.out.println("Successfully wrote to the file"); } catch (IOException e) { System.out.println("Error in closing the File"+e); } try{ System.out.println("File Read now!!!"); File file =new File("D:\\javaFileCode\\Tamima.txt"); Scanner sca = new Scanner(file); while (sca.hasNextLine()){ String data = sca.nextLine(); System.out.println(data); } sca.close(); }catch (IOException e) { System.out.println("Error in closing the file"+e); } } }
Editor is loading...