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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:37:00+00:00 2026-06-11T15:37:00+00:00

I have a file in my resources folder in my project in Eclipse. I

  • 0

I have a file in my resources folder in my project in Eclipse. I need a way in which to load this document into my Java file. Preferable representation would be in an InputStream.

I tried the following based on some searching but it does not seem to be working and I am not sure why (I get null), any help appreciated

InputStream is = getClass().getResourceAsStream("/Project/resources/BlankPDF.pdf");
  • 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-11T15:37:01+00:00Added an answer on June 11, 2026 at 3:37 pm

    The string which you pass as an argument to getResourceAsStream has to be either the location relative to the class you call getResourceAsStream from, or absolute w.r.t. any of your source folders, with a leading /.

    So if resources is a source folder in your project (marked with a little package-like symbol in Eclipse) then getClass().getResourceAsStream("/BlankPDF.pdf") should work.

    Example: Say you have the following folders and packages in your project, source folders being marked with a *:

    Project
        src*
            com.package.foo
                MyClass.java
        resources*
            BlankPDF.pdf
    

    Then both MyClass.class.getResourceAsStream("/BlankPDF.pdf") (leading /, absolute) and MyClass.class.getResourceAsStream("../../../BlankPDF.pdf") (no leading /, relative) should get you the file.

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

Sidebar

Related Questions

I have a Java project which has this file structure (shown in Eclipse): ProjectName
I have added a simple .gif file into Resources folder in my project. Now
I have an Eclipse plugin project that has several file resources that I would
I have a project with a subfolder Resources. In this folder there is a
I have a file paylines.txt added inside the folder named TextFiles which resides inside
I have been given a source folder ( src ) of a Java Project.
In my iPhone project,I need to convert NSData object to file.I have to convert
I a folder structure like so: src\java\com\company\resources\xmlFile.xml The xml file is in the package
I'm trying to export an Eclipse project to a JAR executable file. This project
In eclipse, i have a project i am working on with resources that i

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.