<p>In regular Java, you can get the text of a stack trace by passing a PrintWriter to printStackTrace. I have a feeling I know the answer to this (i.e. "No") but,</p>

<p>Is there any way to obtain the text of a stack trace in JavaME as a String?</p>

<p><strong>Update:</strong></p>

<p>I should mention that I'm restricted to CLDC 1.0</p>

You can have the PrintWriter write to a ByteArrayOutputStream and reconstruct the String from the bytes.
```
```
try{
    throw new Exception("Message");     
} catch (Exception ex){
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ex.printStackTrace(new PrintStream(out));
    System.out.println(new String(out.toByteArray()));
}
```
```
It's not pretty, but it should work pretty much everywhere. Before you try the above, make sure you don't have access to [Throwable#getStackTrace](
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Throwable.html#getStackTrace())
, Eclipse claims it's available in CDC/Foundation 1.1, but that doesn't say anything about other profiles.