import java.io.*;
/**
* StackTraceTest.java
*
*
* Created: Fri Jan 17 13:30:33 2003
*
* @author nikunoki
* @version
*/
public class StackTraceTest {
public StackTraceTest() {}
public static void main(String[] args) {
try {
throw new Exception("test exception");
} catch (Exception ex) {
StringWriter sw = null;
PrintWriter pw = null;
sw = new StringWriter();
pw = new PrintWriter(sw);
ex.printStackTrace(pw);
String trace = sw.toString();
System.out.println("ここから");
System.out.println(trace);
System.out.println("ここまで");
try {
if ( sw != null ) {
sw.flush();
sw.close();
}
if ( pw != null ) {
pw.flush();
pw.close();
}
} catch (IOException ignore){}
}
}
} // StackTraceTest
|