Results 1 to 7 of 7
  1. #1
    shibusbtn is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Red face "java.io.FileNotFoundException" occurs eventhough file present in location

    While try to run code containing the following snippet,I am getting ERROR----
    java.io.FileNotFoundException: C:\Documents and Settings\User_2\workspace\test\src\Login_Credentia ls1.xls (The system cannot find the file specified)
    Please see the code below-
    // Read data from excel sheet
    FileInputStream fi = new FileInputStream("C:\\Documents and Settings\\User_2\\workspace\\test\\src\\Login_Cred entials1.xls");
    Workbook w = Workbook.getWorkbook(fi);
    Sheet s = w.getSheet(0);
    String a[][] = new String[s.getRows()][s.getColumns()];
    // Write the input data into another excel file
    FileOutputStream fo = new FileOutputStream("C:\\Documents and Settings\\User_2\\workspace\\test\\src\\LoginResul t1.xls");
    WritableWorkbook wwb = Workbook.createWorkbook(fo);
    WritableSheet ws = wwb.createSheet("loginresult1", 0);
    Last edited by shibusbtn; 04-04-2011 at 12:42 PM. Reason: For adding editor

  2. #2
    shibusbtn is offline Member
    Join Date
    Apr 2011
    Posts
    2
    Rep Power
    0

    Default

    Tried this code in eclipse.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default

    Then it isn't there.
    List the contents of this directory:
    C:\Documents and Settings\User_2\workspace\test\src

    Oh, and please use code tags when posting code.

  4. #4
    toadaly is offline Senior Member
    Join Date
    Jan 2009
    Posts
    671
    Rep Power
    6

    Default

    It's been a while since I tried to do paths in Windows, but, you may need to escape spaces in file and directory names. Also, you can use unix notation in Java even in windows:

    You might try:

    "C:/Documents\ and\ Settings/User_2/workspace/test/src/Login_Credentials.xls"

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default

    Spaces aren't a problem.

  6. #6
    UJJAL DHAR is offline Senior Member
    Join Date
    Apr 2010
    Location
    Dhaka,Bangladesh
    Posts
    180
    Rep Power
    0

    Default

    Quote Originally Posted by shibusbtn View Post
    While try to run code containing the following snippet,I am getting ERROR----
    java.io.FileNotFoundException: C:\Documents and Settings\User_2\workspace\test\src\Login_Credentia ls1.xls (The system cannot find the file specified)
    Please see the code below-
    // Read data from excel sheet
    FileInputStream fi = new FileInputStream("C:\\Documents and Settings\\User_2\\workspace\\test\\src\\Login_Cred entials1.xls");
    Workbook w = Workbook.getWorkbook(fi);
    Sheet s = w.getSheet(0);
    String a[][] = new String[s.getRows()][s.getColumns()];
    // Write the input data into another excel file
    FileOutputStream fo = new FileOutputStream("C:\\Documents and Settings\\User_2\\workspace\\test\\src\\LoginResul t1.xls");
    WritableWorkbook wwb = Workbook.createWorkbook(fo);
    WritableSheet ws = wwb.createSheet("loginresult1", 0);

    Change all like this.
    FileInputStream fi = new FileInputStream("C://Documents and Settings/User_2/workspace/test/src/Login_Credentials1.xls");
    Don't Forget to try yourself before asking others help.....
    Press REP, if you find their advices/solutions effective.

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,450
    Rep Power
    18

    Default

    Why?
    Apart from the '//' (which is incorrect), the rest is exactly the same as the OP, where '\\' is the equivalent to '/'.

Similar Threads

  1. Replies: 4
    Last Post: 11-05-2010, 11:50 PM
  2. Replies: 8
    Last Post: 03-13-2010, 02:22 PM
  3. Java, Military Format using "/" and "%" Operator!!
    By sk8rsam77 in forum New To Java
    Replies: 11
    Last Post: 02-26-2010, 03:03 AM
  4. Replies: 2
    Last Post: 01-24-2009, 06:56 PM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •