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

  • Home
  • SEARCH
  • 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 926367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:40:29+00:00 2026-05-15T19:40:29+00:00

Before, when I used file in my fileWriter it worked, but now, since I’m

  • 0

Before, when I used file in my fileWriter it worked, but now, since I’m using getResourceAsStream instead of file, how can I make it work?

FileWriter fstream = new FileWriter(new File("filename"), true);

Now, when I pass

InputStream is = getResourceAsStream("filename");
FileWriter fstream = new FileWriter(is, true);

I had to change it, because when I create a runnable jar with the maven assembly plugin there is no src/main/resources in the jar

EDIT:

thanks to casablanca and others for pointing out my mistakes, follow up :

I need to write to a file, but append to it, with preserving the original content. And I need to know to which file I’m writing of course.

  • 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-15T19:40:30+00:00Added an answer on May 15, 2026 at 7:40 pm

    InputStream represents an input stream, so it is not suitable as ouput. You cannot write to an Inputstream. getResourceAsStream return a stream for reading a resource, not for writing to it.

    I’m affraid there is no easy way to write to resource loaded via the ClassLoader. One solution would be to read it as Properties, and then use the store method to write it to a resource file, obtaining the output stream by other means. You can obtain the URI of the resource file using the classloader, but there is no guarantee you can write to it directly (for example if it is bundled in a signed jar).

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

Sidebar

Related Questions

I have a lengthy JavaScript file that passes JSLint except for used before it
I have not used valgrind before, but I need to use it to check
My application uses new proprietary file formats with extensions never been used before. I
never used log4net before, but I may end up kicking myself for that... if
I've used NUnit before, but not in a while, and never on this machine.
I am editing a certain website which before used the port 80 (default) that
Before I used a framework, I'd often define things like so (so my code
What is the meaning of these keywords used before variables in a function parameters?
I'm trying to replicate a template I've used before with a member function, and
I used it before, and was reminded of it when someone asked about a

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.