title: Write file in linux with java isn't working
body: <p>a java code i've been  working in Windows worked perfectly, but when i tried to run it in linux didn't work (i.e it didn't create the file and therefore didn't write)...these are the functions i'm using:</p>
  
  <pre><code>    BufferedWriter writer =null;//
      String directory= "folder/";
      java.io.File directory1 = new File(directory+"resultado");
      String directory2;
      directory1.mkdirs();
  
      directory2=directory+"resultado/";
      try {
      writer = new BufferedWriter(new OutputStreamWriter(
              new FileOutputStream(directory2+"resultado.txt"), "utf-8"));
      writer.write("something");  
      writer.newLine();
      } catch (IOException ex) {
          System.out.println("ERRORR!!!!");
          ex.printStackTrace() ;
          // report
      } finally {
          try {writer.close();} catch (Exception ex) {//ignore}
          }
      }
  </code></pre>
  
  <p>Even thoug i have the catch IOException  to write "Error" it gives me the error</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
      at memoria.bosques.imprimirenarchivos(bosques.java:17281)
      at memoria.bosques.main2(bosques.java:18096)
      at memoria.bosques.main(bosques.java:18139)
  </code></pre>
  
  <p>The folder of the directory is created, but it seems the functions don't create a file to write on it...what can i do?</p>