Java Testing class


public class test {

 public static void main(String[] args) {

   String str = "";
   try {
     BufferedReader in = new BufferedReader(new InputStreamReader(;
     System.out.print( "> ");
     str = in.readLine();
   } catch (IOException e) {

   } // finished reading console input
   try {
     BufferedWriter out = new BufferedWriter(new FileWriter("test.txt"));
   } catch (IOException e) {
   } // finished writing to a file

   System.out.println("Reading the file and printing .... ");
   try {
     BufferedReader in = new BufferedReader(new FileReader("test.txt"));
     String s;
     while ((s = in.readLine()) != null) {
   } catch (IOException e){ 
 } // finished reading the file and printing to std out

See also
Modulus and OpEquals Example
Changing Fahrenheit to Centigrade
Class BRReadLines
Testing class

Do you have a Java Problem?
Ask It in The Java Forum

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of or the content authors.