i have this but i dont understand how to read from a txt file .


Program 35: pr35.java

Write program 30 again, but this time you will read from a txt file. The txt file will have a number followed by that number of sentences.

TXT FILE NAME: pr35.txt

SAMPLE FILE:
3
in the way
choice seats
the batman strikes

SAMPLE OUTPUT:
yaw eht ni
staes eciohc
sekirts namtab eht



Program 35 so far:

import java.io.*;
public class pr35
{
	public static void main(String[]args) throws IOException
	{
	File pr30=new file(pr30.txt);
	StringBuffer contents=new StringBuffer();
	BufferedReader reader= null;
 
	try
	{
	try {
      BufferedReader input =  new BufferedReader(new FileReader(aFile));
      try {
        String line = null; //not declared within while loop
        while (( line = input.readLine()) != null){
          contents.append(line);
          contents.append(System.getProperty("line.separator"));
          }
      }
      finally {
        input.close();
 
      }                  		
   }
}


program 30:

import java.util.Scanner;
public class pr30
{
    public static void main(String[] args) 
    {
    Scanner input=new Scanner(System.in);
    System.out.println ("Please enter a sentence");
    String origstr=input.nextLine();
    StringBuffer buffer=new StringBuffer(origstr);
    buffer=buffer.reverse();
    String reverseString= buffer.toString();
    System.out.println ("reverse: "+ reverseString);
 
    }
 
}

Thanks a lot!
Sincerely,
Ian