Creates a tiny text editor with BufferedReader : Buffered Reader Writer « File Input Output « Java






Creates a tiny text editor with BufferedReader

  

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class TinyEdit {
  public static void main(String args[]) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str[] = new String[100];

    System.out.println("Enter lines of text.");
    System.out.println("Enter 'stop' to quit.");
    for (int i = 0; i < 100; i++) {
      str[i] = br.readLine();
      if (str[i].equals("stop"))
        break;
    }

    System.out.println("\nHere is your file:");

    for (int i = 0; i < 100; i++) {
      if (str[i].equals("stop"))
        break;
      System.out.println(str[i]);
    }
  }
}

   
  








Related examples in the same category

1.Use a BufferedReader to read characters from the console.
2.Read a string from console using a BufferedReader.
3.how to read lines from a file and print these to the standard output stream
4.Writing to a Text File
5.Fast BufferedWriter