Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3421224
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T06:05:08+00:00 2026-05-18T06:05:08+00:00

I am trying to write a method that finds the depth of a file

  • 0

I am trying to write a method that finds the depth of a file system and another that finds the largest file. I have several folders which contain simple text files and are at various depths within the directories. I think there might be a problem with the file input, like it’s not taking anything in or something? Here is the stacktrace:

Exception in thread "main" java.lang.NullPointerException
at FileExploration.largestFile(FileExploration.java:68)
at FileExploration.main(FileExploration.java:14)

Here are the lines that are in this trace:

public static void main (String[] args) {
System.out.println(largestFile(new File(
    "c:/home/skatty14/workspace/LargestFile"))); //Line 14
}

File[] files = h.listFiles();
for (File f: files) { //Line 68
File lf = largestFile(f);

Anyone know how to make it so this will work correctly? I suspect that the input file in line 14 is not being “taken in” properly or something? I have no idea WHY, however…any light that someone can shed on this issue would be much appreciated, thanks!

Edit: Oh, ok…I think I might have found the problem!? I am using Linux: Ubuntu- Lucid Lynx, which doesn’t even have a c:/ HD directory. Although, how do I access a filesystem from Java (in the Home directory in particular)?

Edit2: SOLVED: I just changed the directory to one of my external harddrives. Perhaps permissions were blocking access to the Home folder, I don’t know…I fixed it somehow anyways! 😉

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T06:05:08+00:00Added an answer on May 18, 2026 at 6:05 am

    Path to your home directory on ubuntu; /home/username/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a method that makes a log.txt file if one
I'm trying to write (or just find an existing) PHP method that can take
I'm trying to write a method that will compute all permutations of a power
I am trying to write a method that adapts to different types of interfaces
I'm trying to write a method that removes all non alphabetic characters from a
I'm trying to write a method that acts as a setter and takes some
I am trying to write a method that reads the contents of a richtext
I am trying to write a generic method that would bind any asp.net UI
I’m trying to write a regex/method that extracts Variables from an input String that
I am trying to write a method in Java that accepts a string as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.