1 Reply Latest reply on Mar 22, 2009 9:17 AM by 807588

    FileNotFoundException using FileOutputStream

      Hi everybody,

      While testing the TopLink persistence utility to retrieve some blob stored in a DB, I met the following problem.
      When I run the method :
          private void execute() {
              MediaRetriever mr = new MediaRetriever("tableName");
              MediaBean bean = mr.getMedia(310);
              byte[] buffer = bean.getBuffer();
              String fn = "D:\\Test\\brol\\fil" + String.valueOf(bean.getId()) + "." + bean.getFormat();
              try {
                  FileOutputStream fos = new FileOutputStream(fn);
              } catch (Exception e) {
      my IDE console shows the following message :
      [TopLink Info]: 2009.03.22 12:58:32.068--ServerSession(17459938)--TopLink, version: Oracle TopLink Essentials - 2.0 (Build b58g-fcs (09/07/2007))
      [TopLink Info]: 2009.03.22 12:58:32.720--ServerSession(17459938)--file:/C:/Users/Joe/Documents/JavaProjects/Essais/BrolStorage/dist/BrolStorage.jar-BrolStoragePU login successful
      java.io.FileNotFoundException: D:\Test\brol\fil310.jpg (Syntaxe du nom de fichier, de répertoire ou de volume incorrecte)
              at java.io.FileOutputStream.open(Native Method)
              at java.io.FileOutputStream.<init>(FileOutputStream.java:179)
              at java.io.FileOutputStream.<init>(FileOutputStream.java:70)
              at testbrol.Main.execute(Main.java:30)
              at testbrol.Main.main(Main.java:19)
      Translation of the french text in the exception : syntax error in the file, directory or volume name

      And when I run the program after having replaced the assignment of the String fn this way :
             String fn = "D:\\Test\\brol\\fil310.jpg";
      the program successfully ends and my file is created. But you certainly understand that hard coding is not the way I prefer.
      I've tried a lot of things to solve that problem : replaced the double backslash by a single slash, used StringBuffer, arrays of characters and so on ...
      And now, I'm nearing a brain shortage.
      For your information, I'm using the JDK 1.6.0_02 for compilation and I'm running the latest version of the JVM.

      Any idea ?