title: Write to text file in Java WebService
body: <p>For school I have to make a webservice as a part of a exercise. In this program I must use a .txt file which will serve as a database. When I use a BufferedWriter it says that the information is succesfully written to the file. But the file is still unchanged. Reading from the file went well. Thanks in advance!</p>
  
  <p>The code:</p>
  
  <pre><code>    @WebService
  public class Vak {
  
  @WebMethod
      public boolean addLesson(String lessonname, double mark){       
          if(!lessonname.equals("") || !(mark == 0.00)){
              try{
                  FileInputStream fis = new FileInputStream("C:/marks.txt");
                  DataInputStream in = new DataInputStream(fis);
                  BufferedReader br = new BufferedReader(new InputStreamReader(in));
                  String strLine;         
                  while ((strLine = br.readLine()) != null){
                      String [] splitted = strLine.split(" ");
                      if(splitted[0].equalsIgnoreCase(lessonname)){
                          System.out.println("Lesson already exists");
                          return false;
                      }
                  }           
                  BufferedWriter out = new BufferedWriter(new FileWriter("C:/marks.txt", true));
                  out.newLine();
                  out.write(lessonname + " " + mark);
                  return true;
              }
              catch(Exception e){
                  System.out.println("Exception " + e);
                  return false;
              }
          }   
          return false;
      }
  }
  </code></pre>