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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:58:58+00:00 2026-06-15T17:58:58+00:00

I have following directories structure: UPDATED STRUCTURE src | -test | -java | |

  • 0

I have following directories structure:

UPDATED STRUCTURE

src
 |
 -test
     |
     -java
     |   |
     |   -SomeXmlTest.java
     |
     -resources
          |
          -someXmlContent.xml

I think something like that bad practise:

new File(C:\Project ... \src\resources\someXmlContent.xml)

// or magic dance like that
File currentDir = new File(System.getProperty("user.dir");
File parent = currentDir.getParent();
for (File file:parent.listFiles()){
    //find resources directory and iterate over it files
}

I believe that there is simple annotation base solution, for example I just write “src\resources\someXmlContent.xml” in some annotation and testng resolve path automatically, but how can I do this?

  • 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-15T17:58:59+00:00Added an answer on June 15, 2026 at 5:58 pm

    Use resources instead of files. In this way you can pack your application in a jar and retrieve the resource inside of the jar.

    Use an InputStream instead of a File/FileInputStream:

    InputStream in = getClass().getResourceAsStream("/someXml.xml");
    

    That is a more generic solution than File.

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

Sidebar

Related Questions

I have the following directories structure: g1/ .git a b c/ .git d e
I have a project with the following structure: /. /src /project1 /bin /obj /project2
For my Python application, I have the following directories structure: \myapp \myapp\utils\ \myapp\utils\GChartWrapper\ \myapp\model\
I have the following structure /var/www/mysite/public/ /var/www/mysite/api/ In both directories, .htaccess is set up
I have a set of about 10.000 directories that have the following structure ./AAA/AAA/somedirs/file.txt
I have the following directory structure: test/a test/b/c test/a/b/Ouput test/c/d/e/Output test/f/Output I want to
I have the following program to browse all virtual directories and their sub directories
I have the following situation: multiple virtual directories under same application pool in IIS
I have following plist: <?xml version=1.0 encoding=UTF-8?> <!DOCTYPE plist PUBLIC -//Apple//DTD PLIST 1.0//EN http://www.apple.com/DTDs/PropertyList-1.0.dtd>
I have the following folder structure to my nodeunit tests for a particular project:

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.