Can anyone help me with this please?

Modify the FileTokenTester program from the lecture to reverse the tokens in each input string line and output the reversed version to a file,
apple banana orange strawberry?
becomes
strawberry orange banana apple?
This is all l can do?
class FileTokenTester
public static void main (String args[] )
String inline;
StringTokenizer st;
// file handling is enclosed in a try-catch block as methods called
// may throw exceptions.
try
// set up a Reader on the input file
FileInputStream fis = new FileInputStream("c:\\temp\\inputToken.txt");
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader bf = new BufferedReader(isr);
// set up a Writer on the output file
FileOutputStream os = new FileOutputStream("c:\\temp\\output.txt");
PrintWriter pw = new PrintWriter(os);
// read the first line of input
inline = bf.readLine();
// loop until there is no more input
while (inline != null)
          st = new StringTokenizer(inline );
          while (st.hasMoreTokens())
               pw.println(st.nextToken());
          inline = bf.readLine();
     pw.close(); // have to close the output stream to flush the buffer
// and commit the output.
catch (Exception e)
     System.out.println("Caught Exception: " + e.getMessage()) ;
}

1) Please use code tags. Reinsert your original code, so that the tab spaces remain the same.
2) homework isn't so popular in this forum.
3) If you have any problems, reduce it to the relevant code and post the error message.
4) what is your question, anyway?

Similar Messages

Maybe you are looking for