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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:56:53+00:00 2026-06-14T00:56:53+00:00

I am writing a program that uses jtidy to clean up html from source

  • 0

I am writing a program that uses jtidy to clean up html from source code obtained from a URL. I want to display the errors and warnings in a GUI, in a JTextArea. How would I “reroute” the warnings from printing to stdout to the JTextArea? I’ve looked over the Jtidy API and don’t see anything that does what I want. Anyone know how I can do this, or if it’s even possible?

// testing jtidy options

public void test(String U) throws MalformedURLException, IOException
{
    Tidy tidy = new Tidy();
    InputStream URLInputStream = new URL(U).openStream();
    File file = new File("test.html");
    FileOutputStream fop = new FileOutputStream(file);

    tidy.setShowWarnings(true);
    tidy.setShowErrors(0);
    tidy.setSmartIndent(true);
    tidy.setMakeClean(true);
    tidy.setXHTML(true);
    Document doc = tidy.parseDOM(URLInputStream, fop);
}
  • 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-14T00:56:54+00:00Added an answer on June 14, 2026 at 12:56 am

    Assuming JTidy prints errors and warnings to stdout, you can just temporarily change where System.out calls go:

    PrintStream originalOut = System.out;
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintStream myOutputStream = new PrintStream(baos);
    System.setOut(myOutputStream);
    
    // your JTidy code here
    
    String capturedOutput = new String(baos.toByteArray(), StandardCharsets.UTF_8);
    System.setOut(originalOut);
    
    // Send capturedOutput to a JTextArea
    myTextArea.append(capturedOutput);
    

    There is an analogous method if you need to do this for System.err instead/as well.

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

Sidebar

Related Questions

Overview I am writing a Ruby program that uses data from mysql queries to
I´m writing an program that uses twitter. I want that my app shows an
I am writing a program that uses prints a hex dump of its input.
I'm writing a program that uses regular expressions to make comparisons against the entire
I'm writing a python program that uses scons to build an .exe and then
I'm planning on writing a program for Linux that uses text to speech and
I'm writing a custom text-to-speech program that uses SAPI 5, and one problem I'm
I'm writing a program that for performance reasons uses shared memory (sockets and pipes
I'm writing an MPI program (Visual Studio 2k8 + MSMPI) that uses Boost::thread to
I'm writing a program that uses a mean filter to smooth an image. right

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.