Dukascopy
 
 
Wiki JStore Search Login

printing a StackTrace
 Post subject: printing a StackTrace Post rating: 0   New post Posted: Wed 15 Jun, 2016, 06:19 
User avatar

User rating: 2
Joined: Fri 02 Mar, 2012, 22:08
Posts: 200
Location: New Zealand, Dunedin
my java program has..............

myConsole.getOut().println("Results: " + results);

whenever I wish to output data to view.........

What coding is required to print the StackTrace associated with a java error to the same place?


 
 Post subject: Re: printing a StackTrace Post rating: 0   New post Posted: Wed 15 Jun, 2016, 11:34 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hello,

You have two options:

1)
Thread.currentThread().getStackTrace()
This will return an array of StackTraceElements that represent the current stack trace of a program.
Learn more: here

2)
String fullStackTrace = org.apache.commons.lang.exception.ExceptionUtils.getFullStackTrace(e);
if you use Apache Commons

Good luck and have a nice day


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com