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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:19:22+00:00 2026-06-16T23:19:22+00:00

I have created a JNDI java program that gives different kind of output as

  • 0

I have created a JNDI java program that gives different kind of output as user specification. For example user can run the program with different parameters as :

java MyProg -o row -u username -l uId1,uId2,....

here user can specify options as :
-o : for output format(row basis/column basis)
-u : connect to server with different user(then program will ask for password)
-l : program will show output for given user id(s)

Now the thing is for every option I have define a default value(configuration) so its up to user if he want to change the configuration then he will specify the option. So user can call the program as:

java MyProg
java Myprog -o col
java MyProg -u username 
java MyProg -l uId1,uId2,...
java MyProg -l uId1,uId2,... -o col

and so on..

so whenever user use -u(for changing the username) then the program will ask the password after that it shows the result.

Now I want to provide a facility that user can redirect the console output to a text file but when I am trying “java MyProg > filename.txt” then its not working.

Please tell me how to redirect the output to a file.

  • 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-16T23:19:23+00:00Added an answer on June 16, 2026 at 11:19 pm

    System.out is a PrintStream (which is why you can use such methods as println() etc on it).

    What you can do is, if you see the option to redirect to a file, just create a new PrintStream to the destination file:

    PrintStream stdout = System.out;
    
    // outfile is a String
    if (outfile != null)
        stdout = new PrintStream(outfile);
    

    And use stdout instead of System.out to output results.

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

Sidebar

Related Questions

I have created a function that shows/hides different messages according to a combination of
I have successfully created a disabled user in Active Directory via JNDI, but I
I have created a user defined type to contain some data that I will
I have created some JQuery that will expand a div 'popup' on hover and
I have created an android application that calls (using kSOAP library) a SOAP based
I have created a dialog and got a problem that only part of the
I have a Java web application that uses the SLF4J logging facade. To date,
I have created a Java Web project with just one class. If I compile
I am trying to configure a JNDI data source that can be used from
I have created a QWidget with a bunch of QToolButtons in it and 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.