File.length() returns zero?

Posted on 2007-10-11
Last Modified: 2010-03-30
Dear Experts,

I'm doing:

  File file = new File("c://junk//session.txt");  
  long byteSize = file.length();
  System.out.println("bytes:" + byteSize);

and it's always returning zero.  The file exists, and has stuff in it.  Any ideas?  I've tried it with big and small files.  I'm on W2K if that matters...

Question by:BrianMc1958
    LVL 86

    Accepted Solution


    File file = new File("c:/junk/session.txt");  

    Author Comment

    That works.  It's the damn slash/backslash//escapesequence///!@%$^#&* again...

    LVL 86

    Expert Comment


    Yes - you don't need to double forward slashes - only backward ones ;-)

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    fix34  challenge 9 70
    Connect to IP Camera using Java 4 61
    userCompare  challenge 3 54
    count7 challenge 12 52
    For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
    Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
    Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
    Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now