title: Problems loading resource files
body: <p>Im working on a little programm, which should do the annoying copy&amp;paste stuff for me.
  So i've written a code that allows me to insert the right titles, numbers etc. and that would then copy my inputs in 4 different files at the right place. 
  I have prepared some files (.xml and .html) so that editing is easier.
  Im using a keyword, and then .replaceAll("", "");</p>
  
  <p>My plan is to keep the prepared files as a resource, so i could drag my .jar anywhere on my computer an let the programm generate new files from my resources and also edit files that are in the same directory as my .jar.</p>
  
  <p>Okay so whenever i launch my application via eclipse, everything is fine.
  The programm creates new files based on my inputs using my templates, and edits the existing files i chose to be edited.
  But when i export everything into a .jar the programm stops at a point, without an error or anything like that.</p>
  
  <pre><code>jarpath = getClass().getProtectionDomain().getCodeSource()
              .getLocation().getPath().substring(1);
  //substring removes a / 
  
  jarpathparent = jarpath.replace("alpha.jar", "");
  // replacing with "" to get the only the directory where the .jar is.
  
  
  public void generate(String s) throws IOException {
      String path = "", content = "";
      File file = null, outputfile = null;
      switch (s) {
      case "index":
          Dialog.info("", "1");
          path = getClass().getResource("index.html").toString()
                      .replace("file:/", ""); 
          Dialog.info("", "2");
          file = new File(path);
          Dialog.info("", "3");
          outputfile = new File(jarpathparent + "/index.html");
          Dialog.info("", "4");
          content = FileUtils.readFileToString(file);
          Dialog.info("", "5");
          content = content.replaceAll("XforTitle", title);
          Dialog.info("", "6");
          FileUtils.writeStringToFile(outputfile, content);
          Dialog.info("", "7");
          break;
      case "index2":
                     .
                     .
                     .
  </code></pre>
  
  <p>I have used a little dialog-class i created, to spot where the programm stops.
  The fourth dialogbox is the last one thats popping up, so the problem seem so be </p>
  
  <pre><code> content = FileUtils.readFileToString(file);
  </code></pre>
  
  <p>I dont know exactly whats wrong, but maybe it's because i use apache-commons-io (FileUtils) or something like that?</p>
  
  <p>And maybe a pastebin-link with the whole code:
  <a href="http://pastebin.com/Px7SygYu" rel="nofollow">http://pastebin.com/Px7SygYu</a>
  (The imagelabel and the .wav are just for amusement.)</p>
  
  <p><em><strong></em>__<em>_</em>__<em>_</em>__<em>_</em>__</strong><em>EDIT</em><strong><em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em>__<em>_</em></strong></p>
  
  <p>Okay so i can now load the resource content</p>
  
  <p>by using</p>
  
  <pre><code>InputStream input = getClass().getResourceAsStream("/classpath/to/my/file");
  </code></pre>
  
  <p>and a code-snippet from</p>
  
  <p><a href="http://www.mkyong.com/java/how-to-convert-inputstream-to-string-in-java/" rel="nofollow">http://www.mkyong.com/java/how-to-convert-inputstream-to-string-in-java/</a></p>
  
  <p>So i now have the content of the file as a string, and want to write it to a new file (in the directory, where i put my .jar)</p>
  
  <pre><code>InputStream input = getClass().getResourceAsStream("index.html");
          content = getStringFromInputStream(input);
          Dialog.info("", "2");
          outputfile = new File(jarpathparent + "index.html");
          Dialog.info("", "3");
          content = content.replaceAll("XforTitle", title);
          Dialog.info("", "4");
          Dialog.info("", outputfile.getPath());
          try {
              FileUtils.writeStringToFile(outputfile, content);
          } catch (Exception e) {
              Dialog.vielText("", e.toString());
          }
          Dialog.info("", "5");
  </code></pre>
  
  <p>So it now crashes at FileUtils.writeStringToFile(...);
  but i dont det the dialog with the exception that should be caught in my try catch.
  i checked the outputpath, as you can see in the code, and it seems to be okay.
  Any other ideas on how to fix, or even how to write my string(contains the .html template) to a File ?</p>