FileInputStream FileNotFoundException

OK, for some reason I keep getting a FileNotFoundException in a function that is supposed to load a BufferedImage from file. Take a look at the function and tell me what you think could be the problem.
public static BufferedImage LoadImage(String FileName)
                FileInputStream FIS = new FileInputStream("C:/Objects/" + FileName);
                ObjectInputStream OIS = new ObjectInputStream(FIS);
                BufferedImage BI = (BufferedImage)OIS.readObject();          
                OIS.close();
                FIS.close();
                return BI;
}

So you are saying that what you posted is not the code you actually have and that you can compile and run your code?
You could run the code in a debugger and see what file it is trying to read and checking if that file actually exists. Or add some debug code that checks that the file does exist, like:String completeFileName = "C:/Objects/" + FileName;
System.out.println("Complete file name: <" + completeFileName + ">");
File f = new File(completeFileName);
System.out.println("Does it exist? " + f.exists());

Similar Messages

  • TCK 1.1 File tests fail against CDC-HI-1.1.1-rr-b6

    Dear All,
    Am doing xscale build of CDC-HI-1.1.1-rr-b6 and am running TCK 1.1 against it on a montavista 3.1 platform . Out of 9102 , about 320 tests fail. All the optional packages have been built with the hotspot implementation. The File section of the java_io tests all fail with the harness version 3.2_02 fcs b05 giving the error that
    Directory CDC-TCK-1.1/CDC-TCK_11/tests/api/java_io/File not found. Possible configuration Error
    and all File related tests fail. Other tests that fail are FileDescriptor, FileInputStream, FileNotfoundException,File OutputStream, Filereader,FileWriter,OutputStreamWriter, Serialization components .
    I can for sure see that the File directory exists in java_io dir and the file->serial tests also pass. Any pointers if am missing any enviornment vars or testing with wrong TCK version ?
    regards
    Manav

    Dear All,
    Even i am facing the same problem.
    Getting "Possible configuration Error" for java_io tests.
    Help required!!!
    Thanks in Advance.
    Thanks and Regards,
    Deepraj

  • CDC-TCK1.1 File tests fails against CDC-HI-1.1.1-rr-b36

    Dear All,
    Am doing xscale build of CDC-HI-1.1.1-rr-b6 and am running TCK 1.1 against it . Out of 9102 , about 320 tests fail. All the optional packages have been built with the hotspot implementation. The File section of the java_io tests all fail with the harness version 3.2_02 fcs b05 giving the error that
    Directory CDC-TCK-1.1/CDC-TCK_11/tests/api/java_io/File not found. Possible configuration Error
    and all File related tests fail. Other tests that fail are FileDescriptor, FileInputStream, FileNotfoundException,File OutputStream, Filereader,FileWriter,OutputStreamWriter, Serialization components .
    I can for sure see that the File directory exists in java_io dir and the file->serial tests also pass. Any pointers if am missing any enviornment vars or testing with wrong TCK version ?
    regards
    Manav

    Dear All,
    Even i am facing the same problem.
    Getting "Possible configuration Error" for java_io tests.
    Help required!!!
    Thanks in Advance.
    Thanks and Regards,
    Deepraj

  • File and FileInputStream problem

    Hi all
    I have downloaded from developpez.com a sample code to zip files. I modified it a bit to suit with my needs, and when I launched it, there was an exception. So I commented all the lines except for the first executable one; and when it succeeds then I uncomment the next executable line; and so on. When I arrived at the FileInputStream line , the exception raised. When I looked at the code, it seemed normal. So I want help how to solve it. Here is the code with the last executable line uncommented, and the exception stack :
    // Copyright (c) 2001
    package pack_zip;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import oracle.jdeveloper.layout.*;
    import java.io.*;
    import java.util.*;
    import java.util.zip.*;
    import java.text.*;
    * A Swing-based top level window class.
    * <P>
    * @author a
    public class fzip extends JFrame implements ActionListener{
    JPanel jPanel1 = new JPanel();
    XYLayout xYLayout1 = new XYLayout();
    JTextField szdir = new JTextField();
    JButton btn = new JButton();
    JButton bzip = new JButton();
         * Taille générique du tampon en lecture et écriture
    static final int BUFFER = 2048;
    * Constructs a new instance.
    public fzip() {
    super("Test zip");
    try {
    jbInit();
    catch (Exception e) {
    e.printStackTrace();
    * Initializes the state of this instance.
    private void jbInit() throws Exception {
    this.getContentPane().setLayout(xYLayout1);
         this.setSize(new Dimension(400, 300));
    btn.setText("btn");
    btn.setActionCommand("browse");
    btn.setLabel("Browse ...");
    btn.setFont(new Font("Dialog", 0, 14));
    bzip.setText("bzip");
    bzip.setActionCommand("zipper");
    bzip.setLabel("Zipper");
    bzip.setFont(new Font("Dialog", 0, 14));
    btn.addActionListener(this);
    bzip.addActionListener(this);
    bzip.setEnabled(false);
         this.getContentPane().add(jPanel1, new XYConstraints(0, 0, -1, -1));
    this.getContentPane().add(szdir, new XYConstraints(23, 28, 252, 35));
    this.getContentPane().add(btn, new XYConstraints(279, 28, 103, 38));
    this.getContentPane().add(bzip, new XYConstraints(128, 71, 103, 38));
    public void actionPerformed(ActionEvent e)
    if(e.getActionCommand() == "browse")
    FileDialog fd = new FileDialog(this);
    fd.setVisible(true);
    szdir.setText(fd.getDirectory());
    bzip.setEnabled(true);
    else
              * Compression
         try {
              // création d'un flux d'écriture sur fichier
         FileOutputStream dest = new FileOutputStream("Test_archive.zip");
              // calcul du checksum : Adler32 (plus rapide) ou CRC32
         CheckedOutputStream checksum = new CheckedOutputStream(dest, new Adler32());
              // création d'un buffer d'écriture
         BufferedOutputStream buff = new BufferedOutputStream(checksum);
              // création d'un flux d'écriture Zip
         ZipOutputStream out = new ZipOutputStream(buff);
         // spécification de la méthode de compression
         out.setMethod(ZipOutputStream.DEFLATED);
              // spécifier la qualité de la compression 0..9
         out.setLevel(Deflater.BEST_COMPRESSION);
         // buffer temporaire des données à écriture dans le flux de sortie
         byte data[] = new byte[BUFFER];
              // extraction de la liste des fichiers du répertoire courant
         File f = new File(szdir.getText());
         String files[] = f.list();
              // pour chacun des fichiers de la liste
         for (int i=0; i<files.length; i++) {
                   // en afficher le nom
              System.out.println("Adding: "+files);
    // création d'un flux de lecture
    FileInputStream fi = new FileInputStream(files[i]);
    /* // création d'un tampon de lecture sur ce flux
    BufferedInputStream buffi = new BufferedInputStream(fi, BUFFER);
    // création d'en entrée Zip pour ce fichier
    ZipEntry entry = new ZipEntry(files[i]);
    // ajout de cette entrée dans le flux d'écriture de l'archive Zip
    out.putNextEntry(entry);
    // écriture du fichier par paquet de BUFFER octets
    // dans le flux d'écriture
    int count;
    while((count = buffi.read(data, 0, BUFFER)) != -1) {
              out.write(data, 0, count);
                   // Close the current entry
    out.closeEntry();
    // fermeture du flux de lecture
              buffi.close();*/
    /*     // fermeture du flux d'écriture
         out.close();
         buff.close();
         checksum.close();
         dest.close();
         System.out.println("checksum: " + checksum.getChecksum().getValue());*/
         // traitement de toute exception
    catch(Exception ex) {
              ex.printStackTrace();
    And here is the error stack :
    "D:\jdev32\java1.2\jre\bin\javaw.exe" -mx50m -classpath "D:\jdev32\myclasses;D:\jdev32\lib\jdev-rt.zip;D:\jdev32\jdbc\lib\oracle8.1.7\classes12.zip;D:\jdev32\lib\connectionmanager.zip;D:\jdev32\lib\jbcl2.0.zip;D:\jdev32\lib\jgl3.1.0.jar;D:\jdev32\java1.2\jre\lib\rt.jar" pack_zip.czip
    Adding: accueil188.cfm
    java.io.FileNotFoundException: accueil188.cfm (Le fichier spécifié est introuvable.
         void java.io.FileInputStream.open(java.lang.String)
         void java.io.FileInputStream.<init>(java.lang.String)
         void pack_zip.fzip.actionPerformed(java.awt.event.ActionEvent)
         void javax.swing.AbstractButton.fireActionPerformed(java.awt.event.ActionEvent)
         void javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(java.awt.event.ActionEvent)
         void javax.swing.DefaultButtonModel.fireActionPerformed(java.awt.event.ActionEvent)
         void javax.swing.DefaultButtonModel.setPressed(boolean)
         void javax.swing.plaf.basic.BasicButtonListener.mouseReleased(java.awt.event.MouseEvent)
         void java.awt.Component.processMouseEvent(java.awt.event.MouseEvent)
         void java.awt.Component.processEvent(java.awt.AWTEvent)
         void java.awt.Container.processEvent(java.awt.AWTEvent)
         void java.awt.Component.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
         void java.awt.LightweightDispatcher.retargetMouseEvent(java.awt.Component, int, java.awt.event.MouseEvent)
         boolean java.awt.LightweightDispatcher.processMouseEvent(java.awt.event.MouseEvent)
         boolean java.awt.LightweightDispatcher.dispatchEvent(java.awt.AWTEvent)
         void java.awt.Container.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Window.dispatchEventImpl(java.awt.AWTEvent)
         void java.awt.Component.dispatchEvent(java.awt.AWTEvent)
         void java.awt.EventQueue.dispatchEvent(java.awt.AWTEvent)
         boolean java.awt.EventDispatchThread.pumpOneEvent()
         void java.awt.EventDispatchThread.pumpEvents(java.awt.Conditional)
         void java.awt.EventDispatchThread.run()
    Thank you very much

    One easy way to send a file through RMI is to read all bytes of a file to a byte array and send this array as a parameter of a remote method. But of course you may have problems with memory when you send large files. The receive is simillary.
    Other way is to split the file and getting slices of the file, sending slices and re-assemble at destination. This assume that the file isn't changed through the full transfering is concluded.
    I hope these could help you.

  • PeopleSoft XML Publisher report error with java.io.FileNotFoundException

    Hi,
    I have created two reports using XML Publisher in Peoplesoft Financials. The two reports are not related and they were submitted for processing separately. The first report completes without any issues. The second report results in error with the following message:
    09.11.17 ..(CIS_POTRPT.XML_FILE.Step03) (PeopleCode)
    [012309_091118154][oracle.apps.xdo.template.FOProcessor][EXCEPTION] IOException is occurred in FOProcessor.setData(String) with 'files/cis_potrpt.xml'.
    [012309_091118500][oracle.apps.xdo.template.FOProcessor][EXCEPTION] java.io.FileNotFoundException: files/cis_potrpt.xml (A file or directory in the path name does not exist.)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java(Compiled Code))
         at java.io.FileInputStream.<init>(FileInputStream.java:89)
         at oracle.apps.xdo.template.FOProcessor.getInputStream(FOProcessor.java:1316)
         at oracle.apps.xdo.template.FOProcessor.getXMLInput(FOProcessor.java:1100)
         at oracle.apps.xdo.template.FOProcessor.setData(FOProcessor.java:372)
         at com.peoplesoft.pt.xmlpublisher.PTFOProcessor.generateOutput(PTFOProcessor.java:53)
    2009-01-23-09.11.18.000418 AePcdExecutePeopleCode [174] Exception logged: RC=100.
    Error generating report output: (235,2309) PSXP_RPTDEFNMANAGER.ReportDefn.OnExecute Name:ProcessReport PCPC:51552 Statement:1153
    Called from:CIS_POTRPT.XML_FILE.GBL.default.1900-01-01.Step03.OnExecute Statement:8
    2009-01-23-09.11.18.000617 DoStepActions [1797] Exception logged: RC=100.
    Process 598607 ABENDED at Step CIS_POTRPT.XML_FILE.Step03 (PeopleCode) -- RC = 24 (108,524)
    In the process monitor detail > view log/trace page, the xml file is accessible so the file was generated to a valid directory.
    The weird thing is I was able to run this report without any issues few weeks ago although another user also ran into same error. The PeopleCode step that has been identified is essentially same in the two reports. I checked the app server and the directory does exist as well as the xml files for the two reports. The problem does not occur in test environment, just in production. Any help would be appreciated.

    We encounter the same problem. Did you get the answer for this issue? Thanks in advance.

  • XML Publisher post-processing error 'java.io.FileNotFoundException'

    Hi,
    We are getting following XML Publisher post-processing error while running XML Publisher report.
    It was working earlier but suddenly its erroring out.
    [9/07/10 9:00:17 PM] [OPPServiceThread1] Post-processing request 559655.
    [9/07/10 9:00:18 PM] [39177:RT559655] Executing post-processing actions for request 559655.
    [9/07/10 9:00:18 PM] [39177:RT559655] Starting XML Publisher post-processing action.
    [9/07/10 9:00:18 PM] [39177:RT559655]
    Template code: XXHPOXPRRFLR
    Template app: XXH
    Language: en
    Territory: 00
    Output type: PDF
    [9/07/10 9:00:18 PM] [UNEXPECTED] [39177:RT559655] java.io.FileNotFoundException: /apps/oracle/DEV/inst/apps/DEV_hlt439erplap001/logs/appl/conc/out/o559655.out (No such file or directory)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at oracle.apps.fnd.cp.opp.XMLPublisherProcessor.process(XMLPublisherProcessor.java:274)
         at oracle.apps.fnd.cp.opp.OPPRequestThread.run(OPPRequestThread.java:173)
    [9/07/10 9:00:18 PM] [39177:RT559655] Completed post-processing actions for request 559655.
    Please help me out to resolve this issue.
    Thanks & Regards,
    Sagarika

    Hi,
    java.io.FileNotFoundException: /apps/oracle/DEV/inst/apps/DEV_hlt439erplap001/logs/appl/conc/out/o559655.out (No such file or directory)Most probably this file is not created (since no changes have been done recently, so definitely it is not a permission issue), and if there are any log files generate at the client side it should help in investigating the issue.
    Thanks,
    Hussein

  • Problem with GDS - FileNotFoundException

    I get the following ERROR under heavy load in the server.log when "converting" xml to pdf(generatePDFOutput). Running lc es2(cluster), jboss 4.3, suse linux 11 sp2.
    2014-09-11 15:35:32,950 ERROR [com.adobe.idp.Document] DOCS001: Unexpected exception. An exception while handling a remote request.
    java.io.FileNotFoundException: /srv/global_document_storage/docm1410442494924/b61c1af1ccf663bd8a37be64903d0388 (No such file or directory)
      at java.io.RandomAccessFile.open(Native Method)
      at java.io.RandomAccessFile.<init>(RandomAccessFile.java:216)
      at com.adobe.util.FileUtil.randomAccessRead(FileUtil.java:297)
      at com.adobe.idp.DocumentPullServant.readData(DocumentPullServant.java:168)
      at com.adobe.idp.DocumentPullServant.pullContent(DocumentPullServant.java:154)
      at com.adobe.idp.IDocumentPullServantPOA._invoke(IDocumentPullServantPOA.java:42)
      at org.jacorb.poa.RequestProcessor.invokeOperation(Unknown Source)
      at org.jacorb.poa.RequestProcessor.process(Unknown Source)
      at org.jacorb.poa.RequestProcessor.run(Unknown Source)
    Any idea? No luck with increasing the document disposal timeout or sweep interval...

    Our pdf-files is about the size of 130 kb.
    With the current configuration we have set the document max-inline-size to 512 kb. Now the FileNotFoundException to the GDS has disapeared. But i still wonder why this error was shown when we used the GDS instead on the memory.....
    Could it be problem with Synchronizing clock times in our cluster..?
    Now and then we have another FileNotFoundException ERROR  in the tmp-directory. In what way are LC using this directory..?
    2014-09-18 23:33:58,067 ERROR [com.adobe.idp.Document] DOCS001: Unexpected exception. While doing first time passivation for a document..
    com.adobe.idp.DocumentError: java.io.FileNotFoundException: /tmp/AdobeDocumentStorage/local/docm1411075483830/c694140f75dc873cf6c26afd8e73f57e (No such file or directory)
    at com.adobe.idp.Document.passivateInitData(Document.java:1461)
    at com.adobe.idp.Document.passivate(Document.java:1241)
    at com.adobe.idp.DocumentCallback.handleRemotePassivation(DocumentCallback.java:145)
    at com.adobe.idp.DocumentCallback.handleRemotePassivation2(DocumentCallback.java:189)
    at com.adobe.idp._IDocumentCallbackImplBase._invoke(_IDocumentCallbackImplBase.java:71)
    at org.jacorb.orb.ORB$HandlerWrapper._invoke(Unknown Source)
    at org.jacorb.poa.RequestProcessor.invokeOperation(Unknown Source)
    at org.jacorb.poa.RequestProcessor.process(Unknown Source)
    at org.jacorb.poa.RequestProcessor.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: /tmp/AdobeDocumentStorage/local/docm1411075483830/c694140f75dc873cf6c26afd8e73f57e (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:120)
    at com.adobe.idp.Document.passivateInitData(Document.java:1457)
    ... 8 more

  • FileNotFoundException Uploading image to database

    Hello
    I'm trying to upload image to databases, in my server it works perfectly but when i run the application in the hosting appear FileNotFoundException.
    This is the part of html file than call to servlet.
    <FORM ACTION="http://hosting/servlet/lordcyb3r.Connect">
    <center><h4><b>Insert image</b></h4></center><BR><BR>
         Name:
    <input type="text" class="bginput" name="nombre" value="" size="40"/><BR>
    <input type="hidden" name="c" value=""/>
    <input type="file" class="bginput" name="image" size="40"/><BR>
    Comment:
    <input type="text" class="bginput" name="comentario" value="" size="60"/><BR>
    <INPUT TYPE="SUBMIT" VALUE="Insert">
    </FORM>
    This is the get method of Connect servlet
    protected void doGet(HttpServletRequest request,
                   HttpServletResponse response) throws ServletException, IOException {
              response.setContentType("text/html");
              PrintWriter out = response.getWriter();
              String nombre = request.getParameter("nombre");
              String ruta = request.getParameter("image");
              String comentario = request.getParameter("comentario");
              try {
                   Class.forName("org.gjt.mm.mysql.Driver").newInstance();
                   Connection connection = DriverManager
                             .getConnection("jdbc:mysql://host/db?user=userid&password=psw");
                   PreparedStatement ps = connection
                             .prepareStatement("insert into imagedata values ( ?, ?, ?, ? )");
                   ps.setString(1, nombre);
                   ps.setString(2, ruta.substring(ruta.lastIndexOf("/") + 1));
                   ps.setString(3, ruta.substring(ruta.lastIndexOf(".") + 1));
                   ps.setString(4, comentario);
                   ps.execute();
                   ps = connection
                             .prepareStatement("insert into image values ( ?, ? )");
                   File file = new File(request.getParameter("image"));
                   InputStream is = new FileInputStream(file); // LINE 86 <--- HERE IS THE EXCEPTION
                   ps.setString(1, nombre);
                   ps.setBinaryStream(2, is, (int) file.length());
                   ps.execute();
                   is.close();
                   connection.close();
                   out.println("<br><br>Imagen insertada con �xito");
              } catch (InstantiationException e) {
                   out.println("<br><br>InstantiationException");
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (IllegalAccessException e) {
                   out.println("<br><br>IllegalAccessException");
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (ClassNotFoundException e) {
                   out.println("<br><br>ClassNotFoundException");
                   // TODO Auto-generated catch block
                   e.printStackTrace();
              } catch (SQLException e1) {
                   out.println("<br><br>SQLException");
                   // TODO Auto-generated catch block
                   e1.printStackTrace();
    This is the StackTrace.
    java.io.FileNotFoundException: G-Natalia Duque.jpg (No such file or directory)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at lordcyb3r.Connect.doGet(Connect.java:86)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.caucho.server.http.FilterChainServlet.doFilter(FilterChainServlet.java:95)
         at com.caucho.server.http.Invocation.service(Invocation.java:291)
         at com.caucho.server.http.RunnerRequest.handleRequest(RunnerRequest.java:339)
         at com.caucho.server.http.RunnerRequest.handleConnection(RunnerRequest.java:268)
         at com.caucho.server.TcpConnection.run(TcpConnection.java:136)
         at java.lang.Thread.run(Thread.java:602)
    Can you help me?
    I think so the method is searching the image in the server and no in the client.
    If is this, How can i do it works?
    Thanks for your help.

    to upload the file basic thump rule is the form type is multipart form data and method should be post.
    u have to use any upload component to upload the file from the client machine to the server and then u have to upload it to the database
    baiju

  • File Making Directories Problem. java.io.FileNotFoundException

    When ever I run my program it is SUPPOSED to make the directories, instead it tells me the file doesn't exist and fails.
    Here is my Code:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package passworddatamacsetup;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.swing.JOptionPane;
    * @author jacobgarber
    public class Main {
         * @param args the command line arguments
        public static void main(String[] args) {
            try {
                File PasswordDATA = new File("/Applications/PasswordDATA");
                PasswordDATA.mkdirs();
                File passwords = new File("/Applications/PasswordDATA/PasswordFiles");
                passwords.mkdirs();
                File main = new File("./PasswordDATA_-_MAC.jar");
                File out = new File(PasswordDATA.getPath()+"/PasswordDATA.jar");
                copy(main, PasswordDATA);
                JOptionPane.showMessageDialog(null, "Framework setup complete!", "Completed!", JOptionPane.INFORMATION_MESSAGE);
            } catch(Exception ex) {
                JOptionPane.showMessageDialog(null, ex);
        // Copies src file to dst file.
        // If the dst file does not exist, it is created
        public static void copy(File src, File dst) throws IOException {
            try {
                InputStream in = new FileInputStream(src);
                OutputStream out = new FileOutputStream(dst);
                // Transfer bytes from in to out
                byte[] buf = new byte[1024];
                int len;
                while ((len = in.read(buf)) > 0) {
                    out.write(buf, 0, len);
                in.close();
                out.close();
            } catch (FileNotFoundException ex) {
                JOptionPane.showMessageDialog(null, ex);
    }Here is my exception:
    java.io.FileNotFoundException: /Applications/PasswordDATA

    This looks suspicious:
                File out = new File(PasswordDATA.getPath()+"/PasswordDATA.jar");
                copy(main, PasswordDATA);You probably meant:
                File out = new File(PasswordDATA.getPath()+"/PasswordDATA.jar");
                copy(main, out);

  • FileInputStream

    I have a zip file in directroy A.i'm unzipping the the zip file,creating a new directory in another folder and writing the file to the new folder.But its threowing me a file not found exception.Its creating problem in the FileInputStream.Suggestions plz...

    ZipFile zFile = new ZipFile(tempFile);
    Enumeration zipEntries = zFile.entries();
    String logFile = null;
    String fExtn=null;
    String gbsFile=null;
    while(zipEntries.hasMoreElements())
    ZipEntry zEntry = (ZipEntry)zipEntries.nextElement();          
    String fName = zEntry.getName();
    fExtn = fName.substring(fName.length()-3);
    fName=fName.substring(fName.indexOf("/")+1);
    File f;
    File fDir = new File(TMPHome+"\\BRCFiles");
    fDir.mkdirs();
    f=new File(fDir,fName);
    FileInputStream fis=new FileInputStream(f);
    BufferedInputStream inr= null;
    FileOutputStream fout=new FileOutputStream(f.getPath());
    BufferedOutputStream out=new BufferedOutputStream(fout);
    byte [] fileData = null;
    int readCount=0;
    try{
    inr = new BufferedInputStream(fis);
    while ((readCount = inr.read()) > -1)
    out.write(readCount);
    out.flush();
    fis.close();
    fout.close();
    inr.close();
    out.close();
    catch (FileNotFoundException e)
    {e.printStackTrace();
    catch (IOException e)
    {e.printStackTrace();
    }//end of while

  • FileNotFoundException when using the Help.addBook method

    Hi,
    I tried to use the following code:
    HelpSet helpSet = new HelpSet(myUrl);
    Help help = new Help();
    help.addBook(helpSet);
    However, when trying to launch my application, a "FileNotFoundException: c:\Documents%20and%20Settings\...\myToc.xml" is thrown !
    This problem occurs when using the JDK 1.4 (it does not seem to depend on the version of Oracle Help for Java: I tried to use successively 4.1.16, 4.1.17 and 4.2 versions !).
    When developping my own application, I encountered a similar problem and found that it was related to a change in the java API. More precisely, prior to JDK 1.4 beta, getClass().getResource("myFile").getFile() would return "/c:/Documents and Settings/myFile" which could be used to read "myFile". But in JDK 1.4 beta, it returns a location that has spaces translated into %20 characters ("/c:/Documents%20and%20Settings/myFile") which cannot be used as a valid file name in java.io.File or java.io.FileInputStream classes.
    Could you help me ?
    Carine.

    Hi,
    "myUrl" is the url of my "helpset.hs" file.
    This file is written as follow:
    <helpset>
    <title>Validation</title>
    <maps>
    <homeID>top</homeID>
    <mapref location="validation_map.xml"/>
    </maps>
    <view>
    <title>Table of Contents</title>
    <label>Table of Contents</label>
    <type>oracle.help.navigator.tocNavigator.TOCNavigator</type>
    <data engine="oracle.help.engine.XMLTOCEngine">validation_toc.xml</data>
    </view>
    <view>
    <title>Index</title>
    <label>Index</label>
    <type>oracle.help.navigator.keywordNavigator.KeywordNavigator</type>
    <data engine="oracle.help.engine.XMLIndexEngine">validation_index.xml</data>
    </view>
    <view>
    <title>Search</title>
    <label>Search</label>
    <type>oracle.help.navigator.searchNavigator.SearchNavigator</type>
    <data engine="oracle.help.engine.SearchEngine">validation_search.idx</data>
    </view>
    </helpset>
    Thank you,
    Carine.

  • FILENOTFOUNDEXCEPTION while reading property files in Tomcat 6------Help me

    Hi All
    I am planning to migrate my web application from iplanet 4.1 to tomcat 6. In this process I need to read the properties files initially.
    for eg: i got the property files in a iPlanet:
    Config directory---
    abc.properties.---
    abc.log--
    In tomcat I configured them in web.xml saying that.
    <servlet>
    <servlet-name>ABC</servlet-name>
    <servlet-class>com.ijk.abc</servlet-class>
    <init-param>
    <param-name>Loan</param-name>
    <param-value>/WEB-INF/config</param-value>
    </init-param>
    <init-param>
    <param-name>loan.props</param-name>
    <param-value>/WEB-INF/config/abc.props</param-value>
    </init-param>
    <init-param>
    <param-name>loan.log</param-name>
    <param-value>/WEB-INF/config/abc.log</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    </servlet>
    <servlet-mapping>
    <servlet-name>ABC</servlet-name>
    <url-pattern>/</url-pattern>
    </servlet-mapping>
    I need to read initially all the property files and then proceed.
    While configuring in this way, it am getting error saying that
    abc.props or abc.log..............(FILE NOT FOUND EXCEPTION)
    Can anyone suggest me how to configure them.
    Thanks in Advance.

    Thanks for your response, Actually we dont have the source code for that because it is very old code, but i m using decompiler in which i can get some informtaion.
    OS used for iPlanet is Unix but now I need to deploy this application in tomcat in windows server 2003.
    Servlet clss:
    SERVLET CLASS:
    Class com.ijk.abc implements extends HttpServlet  implements PropertyKeys
    private IClickManager m_im;
    public void init(ServletConfig paramServletConfig)
        throws ServletException
        Utils.info("Servlet initialization");
        try {
          super.init(paramServletConfig);
          Utils.info("ServerInfo: " + getServletContext().getServerInfo());
          PGroup localPGroup = this.m_im.claimPG();
          Utils.trace("Got " + localProcessorGroup + " for initialization");
          this.m_im.gatherProperties(localProcessorGroup);-----------this is where it is calling the property files.
          this.m_im.freePG(localPGroup);
          Utils.trace("Released " + localPGroup + " for new Properties");
          localPGroup = this.m_im.claimPG();
          Utils.trace("Got " + localPGroup + " for new Properties");
          try
            ConHandler localDBHandler = (ConHandler)localPGroup.getDBHandler("config.dbhandler");
            this.m_im.setNumPGs(localDBHandler.getNumPGroups());
          catch (Exception localException1) {
            Utils.info("NON FATAL ERROR: failed to set number of PGs", localException1);
          try
            Session.createAndStartSessionTask(localPGroup);
            localPGroup.resumeAllTasks();
          catch (Exception localException2) {
            Utils.info("NON FATAL ERROR: failed to start tasks", localException2);
          this.m_im.freePG(localPGroup);
          Utils.trace("Released " + localPGroup + " for initialization");
          Utils.info("Servlet initialization finished");
        catch (FatalServletError localFatalServletError) {
          Utils.error("FatalServletError: ", localFatalServletError);
          throw new UnavailableException(this, localFatalServletError.toString());
        catch (Error localError) {
          Utils.error("Error: ", localError);
          throw localError;
    ==========================================================
    public void gatherProperties(ProcessorGroup paramProcessorGroup)
        Object localObject;
        this.m_props.clear();
        String str1 = this.m_servlet.getInitParameter("loan.dir");
        if (str1 == null) {
          str1 = System.getProperty("server.root", System.getProperty("user.dir", "."));
        this.m_props.put("loan.dir", str1);
        String str2 = this.m_servlet.getInitParameter("abc.log");
        setLogFile(str2);
        try
          String str3 = this.m_servlet.getInitParameter("abc.props");
          if (str3 == null)
            str3 = "abc.props";
          localObject = str1 + File.separator + str3;
          Utils.info("Reading properties from file: " + ((String)localObject));
          Utils.loadProperties(this.m_props, new BufferedInputStream(new FileInputStream((String)localObject)));
        catch (IOException localIOException) {
          Utils.info("NON FATAL WARNING: Could not read props file", localIOException);--while running i m getting this error
        Utils.info("Reading properties from Servlet Parameters");
        Enumeration localEnumeration = this.m_servlet.getInitParameterNames();
        while (localEnumeration.hasMoreElements()) {
          localObject = (String)localEnumeration.nextElement();
          this.m_props.put(localObject, this.m_servlet.getInitParameter((String)localObject));
        Utils.info("Reading properties from DB");
        try {
          localObject = (ConDBHandler)paramProcessorGroup.getDBHandler("config.dbhandler");
          String str5 = ((ConDBHandler)localObject).getPropertiesFile();
          Utils.loadProperties(this.m_props, new ByteArrayInputStream(str5.getBytes()));
        catch (Exception localException) {
          Utils.info("NON FATAL WARNING: Could not read props file", localIOException);--while running i m getting this error
        String str4 = this.m_props.getProperty("smtp.host");
        if (str4 != null) MailUtils.setSMTPHost(str4.trim());
        if (str2 == null) {
          str2 = this.m_props.getProperty("abc.log");
          setLogFile(str2);
         runInitializers(paramPGroup);
        Utils.info("New Properties:", this.m_props);
        this.m_rroots = StringUtils.getPathsFromList(this.m_props.getProperty("resource.path", "/com/loan/resources/:/"));
        clearAllPGs();
    =================================================================
    the above is the servlet class and the method which is using to read the property files from root directory in Unix.
    ie../opt/mywebapp/loan/abc.props,abc.log
    loan is the directory in which two property files are placed.
    i just want to where to place property files in tomcat so that its going to read the property files.
    Right now, i placing it in the WEBAPPS/MYWEBAPPLICATION/WEB-INF/LOAN/abc.props,abc.logs.
    Its giving me errors such as FILENOTFOUNDEXCEPTION or cannot read the property files.
    The main problem is ...I donot have the complete source code. while decompiling i m not able view complete source code.
    Please help me regarding this.........
    Thanks in advance.

  • FileNotFoundException at new GregorianCalendar() in 1.4.2_02

    The following exception is thrown in windows platform of j2sdk 1.4.2_02 (also in 03) when I create a new GregorianCalendar
    Thread [main] (Suspended (exception FileNotFoundException))
         FileInputStream.open(String) line: not available [native method] [local variables unavailable]
         FileInputStream.<init>(File) line: 106
         ZoneInfoFile$1.run() line: 910
         AccessController.doPrivileged(PrivilegedExceptionAction) line: not available [native method]
         ZoneInfoFile.readZoneInfoFile(String) line: 904
         ZoneInfoFile.createZoneInfo(String) line: 520
         ZoneInfoFile.getZoneInfo(String) line: 499
         TimeZone.parseCustomTimeZone(String) line: 633
         TimeZone.getTimeZone(String, boolean) line: 450
         TimeZone.getDefault() line: 522
         GregorianCalendar.<init>() line: 336
         MyTest.<clinit>() line: 28The source is
    public class MyTest {
         private static Calendar cal = new GregorianCalendar();
         Does anyone know of any cure?
    Thanks a lot.
    Gary.

    I don't think you can do new GregorianCalendar, but you need to use Calendar.getInstance().
    Read more at:
    http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html
    Here is some:
    Calendar is an abstract base class for converting between a Date object and a set of integer fields such as YEAR, MONTH, DAY, HOUR, and so on. (A Date object represents a specific instant in time with millisecond precision. See Date for information about the Date class.)
    Subclasses of Calendar interpret a Date according to the rules of a specific calendar system. The platform provides one concrete subclass of Calendar: GregorianCalendar. Future subclasses could represent the various types of lunar calendars in use in many parts of the world.
    Like other locale-sensitive classes, Calendar provides a class method, getInstance, for getting a generally useful object of this type. Calendar's getInstance method returns a Calendar object whose time fields have been initialized with the current date and time:
    Calendar rightNow = Calendar.getInstance();
    A Calendar object can produce all the time field values needed to implement the date-time formatting for a particular language and calendar style (for example, Japanese-Gregorian, Japanese-Traditional).
    Gil

  • Java.io.FileNotFoundException: test.txt (The system cannot find the file sp

    Hi All,
    am getting the following error, help me out. Thanks in advance...
    java.io.FileNotFoundException: test.txt (The system cannot find the file specified)
         java.io.FileInputStream.open(Native Method)
         java.io.FileInputStream.<init>(FileInputStream.java:106)
         java.io.FileInputStream.<init>(FileInputStream.java:66)
         BinaryStreamServlet.doGet(BinaryStreamServlet.java:13)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    I have placed "test.txt" in the path"D:\Backup\Tomcat web server\apache-tomcat-6.0.14\webapps\examples\WEB-INF\classes\test.txt".
    web.xml entry is as follows,
    <servlet>
    <servlet-name>demoservlet2</servlet-name>
    <servlet-class>BinaryStreamServlet</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>demoservlet2</servlet-name>
    <url-pattern>/demoservlet2</url-pattern>
    </servlet-mapping>
    Source code:
    import java.io.*;
    import java.net.*;
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class BinaryStreamServlet extends HttpServlet{
    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException{     
    response.setContentType("text/plain"); /* set the MIME type */
         File f= new File("test.txt");
         byte[] arBytes = new byte[(int) f.length()];
         FileInputStream is= new FileInputStream("test.txt");
         is.read(arBytes);
         OutputStream os = response.getOutputStream();
         os.write(arBytes);
         os.flush();
    }

    I have one Drivers.xml file in /WEB-INF that i want to read .but everytime i get exception file not found..
    i m trying to read this xml file in DriverUtilties.java (a non servlet class)
    inside of /WEB-INF/classess folder is there and hierarchy for non-servlet class DriverUtilties is :- com.dds.apps.ptes.pidentifier.admin.util.common.DriverUtilties
    what code shall i write so that i can read the xml file. ???
    where i set in classpath ?
    MYCODE is like this :
    public static final String DEFAULT_FILE = "/WEB-INF/drivers.xml";
    InputStream in = new FileInputStream(DEFAULT_FILE);
    Thanks in advance

  • Opening FileInputStream() deletes my files

    hi, im currently developing a java app under suse linux and have a problem when opening FileInputStream().
    if we take the example;
    String path = new String( /dev/java/);
    FileInputStream stream = new FileInputStream(path + "/default/myfile");
    a java.io.FileNotFoundException: is always thrown.
    for some reason java deletes the /default/ folder when trying to open it, but the /dev/java/ folders are left unharmed.
    does anyone have any ideas?

    String path = new String( /dev/java/);It won't compile outside "".
    Under /dev usually the special device files dwell.
    Is there /dev/java ? Is it not a typo?

Maybe you are looking for

  • How can I turn off smooth scrolling in Lion?

    I can't not turn off smooth scrolling. Actually, I don't want to use smooth scrolling in Lion OS. How can I turn off smooth scrolling in Lion? In case of Leopard, there is option on  "System Preferences, Appearance". Please help me.

  • Getting started - What libraries to rely on?

    Hi all, I want to get started with a web project using JSF. What libraries/frameworks should this web project be based on? I have taken a quick look at MyFaces, Facelets and Apache Shale. Because I am new to the topic I cannot not judge what the best

  • Change Currency

    Hi, How can I add a new currency to a Employee. An Employee is being paid in USD.. I need to change the Currency so that he could be paid in local currency. Regards Jdev..

  • Is it possible to get your crediti card cloned at ITunes?

    I have my credit card cloned this second semester. Since I use it all onver the place, I didn´t think it was due the registration on ITunes. Now, in november, I got my second credit card cloned, shortly after changing my registration info on ITunes.

  • Can't get OCZ Agility 60GB to work

    I purchased an OCZ Agility SSD a few days ago but have been unable to get it working. Whenever I try to install Snow Leopard, the install process fails after about 30 minutes with the message: "Install failed. Mac OS X could not be installed on your