Wednesday, July 3, 2019

1. Read the content of a text file and display the content 2. Write the content provided by the user into a text file.

1. Read the content of a text file and display the content
2. Write the content provided by the user into a text file.

/**
 * @(#)javaread.java
 *
 * javaread application
 *
 * @author 
 * @version 1.00 2019/7/1
 */
 import java.io.*;
 import java.util.Scanner;
 
 
public class javaread {
    
    public static void main(String[] args) {
     
    File myfile = new File ("C:\\Users\\Anonymous\\Desktop\\test.txt");
    try{
     BufferedReader br = new BufferedReader (new FileReader (myfile));
     String text;
     while ((text=br.readLine())!=null){
      System.out.println(text);
     }
     
    }catch(IOException e){
     System.out.println("File does not exit");
     
    }
    }


1. Read the content of a text file and display the content 2. Write the content provided by the user into a text file./**
 * @(#)javaread.java
 *
 * javaread application
 *
 * @author 
 * @version 1.00 2019/7/1
 */
 import java.io.*;
 import java.util.Scanner;
 
 
public class javaread {
    
    public static void main(String[] args) {
     
    File myfile = new File ("C:\\Users\\Anonymous\\Desktop\\test.txt");
    try{
     BufferedReader br = new BufferedReader (new FileReader (myfile));
     String text;
     while ((text=br.readLine())!=null){
      System.out.println(text);
     }
     
    }catch(IOException e){
     System.out.println("File does not exit");
     
    }
    }
}

0 comments:

Post a Comment