Hi i have to make this program that will read a message from another text file and surround each occurence of an abbreviation with <> brackets. and the write the marked message to a different file. The program must beable to read from a text file that contains the abbreviations and a text file that contains the message. Could someone please tell me if I am on the right track?
package abbreviationstest;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.util.Scanner;
import java.io.FileNotFoundException;
/**
*
* @author 420
*/
public class abbreviationsTest
{
public static void main(String[] args)
{
String fileName = "abbreviations.txt";
Scanner inputStream = null;
System.out.println("The file " + fileName + " contains the following lines:");
try
{
inputStream = new Scanner(new File(fileName));
//messageInputStream = new Scanner(new File(fileName));
}
catch(FileNotFoundException e)
{
System.out.println("Error opening the file " + fileName);
}
while (inputStream.hasNextLine())
{
String line = inputStream.nextLine();
System.out.println(line);
}
inputStream.close();
String message = "message.txt";
//FileOutputStream// messageOutputStream =
try
{
FileOutputStream outputStream = new FileOutputStream(new String(message));
System.out.println("The file " + message + " contains the following lines:");
Scanner keyboard = new Scanner(new File(message));
String newMessage = message;
do
{
newMessage = keyboard.next();
outputStream.toString();
}
while(newMessage.matches(message));
{
System.out.print(newMessage);
}
}
catch(FileNotFoundException e1)
{
System.out.println("Error opening the file " + message);
}
}
}