Implementing the WriteFileOnTextArea() Method
The method WriteFileOnTextArea() is defined in the class, File_class. The method is used to write in the FileOutput.txt.
Declaration of the method, WriteFileOnTextArea()
public void WriteFileOnTextArea()// Method to write in the file.
{
String str;
char st;
str="";
try
{
DataInputStream If=new DataInputStream(new FileInputStream("FileOut.txt"));
while(If.readLine()!=null)
{
if ((st=If.readChar())!='E')
{
str=st+str;
}
if (st=='E')
{
textarea1.setText("");
textarea1.append(str);
textarea1.append("n");
str="";
}
}//Ed while.
If.close();
}//End try.
catch(FileNotFoundException e){} //Catches the error if the file is not found.
catch(IOException e) {}
}// End of method WriteFileOnTextArea().
The above listing shows the declaration of the WriteFileOnTextArea() method. The WriteFileOnTextArea() method reads a file named FileOutput.txt. The method also catches the FileNoteFoundException exception if the file FileOuput.txt does not exits.
0 Comments:
Post a Comment