title: Spring service layer write file
body: <p>I have this method in spring service layer. But it cannot write to file and there is no exception. What's wrong with my code?   </p>
  
  <pre><code>public void addLineToFile(String file, String line) {
      try {
          ClassPathResource cpr = new ClassPathResource(file);
          FileOutputStream outputStream = new FileOutputStream(cpr.getFile());
          outputStream.write(line.getBytes());
          outputStream.close();
      } catch (FileNotFoundException ex) {
          Logger.getLogger(CustomerToFile.class.getName()).log(Level.SEVERE, null, ex);
      } catch (IOException ex) {
          Logger.getLogger(CustomerToFile.class.getName()).log(Level.SEVERE, null, ex);
      }
  }
  </code></pre>