Hi friends ,
I have created a student marklist program in
Java using files . The aim of the program is to read the contents from the console , calculate the total and display it in the console as well as write to a file . I am not able to write the contents into the file . I am not able to figure out the problem . Please let me know the details ....
Thanks in advance ....
import java.io.*;
public class u3
{
public static void main (
String [] args) throws IOException
{
String name;
String mark1,mark2;
double m1,m2,total,letter;
BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
BufferedWriter br2 = new BufferedWriter (new FileWriter("oo.txt"));
try
{
System.out.println("Enter the name:");
name=br.readLine();
System.out.println("Enter the mark1:");
mark1=br.readLine();
m1=Double.parseDouble(mark1);
System.out.println("Enter the mark2:");
mark2=br.readLine();
m2=Double.parseDouble(mark2);
total=m1+m2;
System.out.println(total);
while((letter=br.read()) != -1) {
br2.write((char) letter);
br2.flush(); }
System.out.println("written successfully");
}
catch(IOException e)
{
}
}
}