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 8767553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:50:41+00:00 2026-06-13T16:50:41+00:00

I’m not sure if I’m doing this correctly. I want to have a folder

  • 0

I’m not sure if I’m doing this correctly.
I want to have a folder or package in my Java project that contains a bunch of text files. In code, I want to list all of the files in the folder, and be able to read them. I want these resource files to be part of my project’s directory structure (so that they can be version controlled with my source).

I have seen the ClassLoader.*resource methods but can’t identify a folder in my source directories and list it’s contents…

BTW I’m using Eclipse.
Does anybody know how to do achieve this goal?

Thanks

==========================================

UPDATE:

Thanks for the replies! I found that by adding the source folder, I can only access the files inside by name. This doesn’t fit my needs however, as the contents of the folder will change, and I want to be able to read all the contents dynamically, without having to change the read logic every time the contents change. I tried creating a File for a regular folder within the source folder and iterating over it’s contents. That works as long as run in Eclipse, but as per Edwin’s comment, this will not work when I export to a JAR, so I’m back at square one.

I’m thinking there MUST be a way to include resource files in my project that I can access programmatically (Android does this and it’s based on java right?). So is there another way to create a ‘resources’ package containing a bunch of files that I can access at runtime without having to update code to look for each file? I really don’t want to have to separate this folder from my source and maintain it in a different location as this will complicate deployment…
Does anybody have any ideas?

Thanks

====================================

Solution:

I just realized that Android inventories it’s resource files at compile time in order to make them available at runtime. So this is probably the way to go: I’ll just add a step to my Ant script that writes a file (always named the same so i can access it) containing a list of the files in my folder. This way I’ll know the names of all my available resource files. Thanks Edwin for your help 🙂

  • 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-06-13T16:50:42+00:00Added an answer on June 13, 2026 at 4:50 pm

    Make sure your resource folder is a source folder in the Eclipse Build Path dialog box. Then you will able to load them with the ClassLoader method that you mentioned in the question.

    enter image description here

    If you use this technique, every subfolder within the source folder is considered a package. So make sure to take that into account when you load the resource.

    This technique basically makes sure that all Java the files in this folder are compiled and placed under the distribution folder. And any other files are simply copied from this folder to the distribution folder (i.e. the bin or classes folder).

    Later, when you package your project into a jar or war, you have to make sure this files are included within the packaged file.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a small JavaScript validation script that validates inputs based on Regex. I
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms
I know there's a lot of other questions out there that deal with this

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.