我需要在Java中的文本文件中捕获异常.例如:
try {
File f = new File("");
}
catch(FileNotFoundException f) {
f.printStackTrace(); // instead of printing into console it should write into a text file
writePrintStackTrace(f.getMessage()); // this is my own method where I store f.getMessage() into a text file.
}
Run Code Online (Sandbox Code Playgroud)
使用getMessage()作品,但它只显示错误消息.我想要printStackTrace()包含行号的所有信息.