Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: read file Java

  1. #1
    Regular Coder
    Join Date
    Aug 2002
    Posts
    439
    Thanks
    3
    Thanked 0 Times in 0 Posts

    read file Java

    Take a look at the following code:
    try{

    url=new URL ("http://www.ora.com/images/logo.jpg");
    InputStream in = null;
    in=url.openStream();
    BufferedReader bf = null;
    bf=new BufferedReader(new java.io.InputStreamReader(in));
    theString=bf.readLine();
    }catch(Exception e){
    System.out.println("Something is wrong");
    }

    I have put a breakpoint at the first line (url=new...). I have noticed that at execution time an exception occurs "Something is wrong"-->message.
    What is wrong with it?
    I have also tried the
    url=new URL (getDocumentBase(),MyFileName);
    but still no effects

  • #2
    Regular Coder
    Join Date
    Dec 2003
    Posts
    367
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Checking the exception might give you a better clue:
    Code:
    // ...
    catch (Exception e) {
      System.out.println("Something is wrong - " + e);
      e.printStackTrace();
    }
    shmoove


  •  

    Posting Permissions

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