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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:47:19+00:00 2026-06-02T10:47:19+00:00

I am currently reading in a public key file using the following code: //

  • 0

I am currently reading in a public key file using the following code:

    // Read Public Key.
    File filePublicKey = new File(path + "/public.key");
    FileInputStream fis = new FileInputStream(path + "/public.key");
    byte[] encodedPublicKey = new byte[(int) filePublicKey.length()];
    fis.read(encodedPublicKey);
    fis.close();

However, I wish to include the key files in with my jar. I have dragged the key files into my project in eclipse and I am trying to load the public key using the following to replace what is above:

    InputStream is = getClass().getResourceAsStream( "/RSAAlgorithm2/public.key" );
    byte[] encodedPublicKey = new byte[(int) 2375];
    is.read(encodedPublicKey);
    is.close();

However I keep getting a NullPointerException.

java.lang.NullPointerException at RSA.LoadKeyPair(RSA.java:122) at
RSA.main(RSA.java:31)

Is this because I am incorrectly loading in the file? Can files be dragged into eclipse and loaded like this or is it a requirement to have them seperate from the JAR?

  • 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-02T10:47:28+00:00Added an answer on June 2, 2026 at 10:47 am

    Check if is is null after doing getResourceAsStream. If it is, the resource has not been found. In this case check the path to the file, it is relative to your classpath. I don’t know your project setup but I would try to simply use "/public.key"…

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

Sidebar

Related Questions

I'm currently using such blocks of code in my project public ActionStatus GetStuff(out output)
I am new to php and currently I am reading Wrox Professional PHP 5.
I'm currently reading the boot.s file in the source for the first ever Linux
I am currently reading an existing code in MS Visual C++ 6.0. I notice
First off: I'm new to both Qt and SWIG. Currently reading documentation for both
I am currently reading an WPF tutorial and i don't fully understand the following
I currently have healthmonitoring implemented for a public facing website. I am using the
I am currently reading Effective C# and found the following line very confusing: Last,
I'm currently reading in MIDI messages in real-time from my midi keyboard using a
I'm currently reading Jon Skeet's C# in depth 2nd edition and the following question

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.