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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:26:12+00:00 2026-06-07T02:26:12+00:00

Here is my code that I have which is pretty simple and to the

  • 0

Here is my code that I have which is pretty simple and to the point:

public void sendMessage(String message)
{
    writer.println(message);
    writer.flush();
}

I don’t really like to use PrintWriter cause it tends to swallow IOExceptions, this is really the only thing I’m using it for besides sending byte arrays. What can I use instead that won’t consume IOExceptions and will still give me the functionality of PrintWriter?

  • 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-07T02:26:14+00:00Added an answer on June 7, 2026 at 2:26 am

    I’d recommend using a plain Writer or a BufferedWriter

    public void writeMessage(BufferedWriter bw, String message) throws IOException {
        bw.write(message);
        bw.newline();
        bw.flush();
    }
    

    or

    public void writeMessage(Writer writer, String message) throws IOException {
        writer.write(message);
        writer.write(System.lineSeparator());
        writer.flush();
    }
    

    But obviously it depends on what functionality of PrintWriter you want to retain.

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

Sidebar

Related Questions

I have a ListActivity which has an adapter that crashes. Here is the code
Here is the code that I have for my cell of my UITableView: forKeys:[NSArray
Here's the c# code that I have: private double get806Fees (Loan loan) { Loan.Fee.Items
enter code here I have a ListView that have a different Layout XML for
Here is the piece of code that I have used for Java 5.0 TreeSet<Integer>
I have some code here that uses bitsets to store many 1 bit values
I have the following code here that won't run on ARC since it combines
I have a piece of code here that does not work despite me using
I have no idea what this means. But here is the code that it
Basic question here - I have many lines of code that look something like:

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.