List of usage examples for java.io PrintWriter PrintWriter
public PrintWriter(File file) throws FileNotFoundException
From source file:Main.java
public static String getStackTrace(Throwable aThrowable) { final Writer result = new StringWriter(); final PrintWriter printWriter = new PrintWriter(result); aThrowable.printStackTrace(printWriter); return result.toString(); }
From source file:Main.java
public static String getStackTrace(Throwable exception) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); exception.printStackTrace(pw);/*ww w . jav a 2 s . c o m*/ return sw.toString(); }
From source file:Main.java
public static String getCurrentThreadStack() { StringWriter sw = new StringWriter(); new Throwable("").printStackTrace(new PrintWriter(sw)); return "\n" + sw.toString(); }
From source file:Main.java
static void printE(String tag, Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw);/*from w w w. j a v a 2s . co m*/ Log.e(tag, sw.toString()); }
From source file:Main.java
public static void writeToFile(File file, String content) { try {/*from w ww . j a v a2 s . c om*/ PrintWriter out = new PrintWriter(file); out.println(content); out.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } }
From source file:Main.java
public static String exception2String(Exception e) { ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(); PrintWriter err = new PrintWriter(arrayOutputStream); e.printStackTrace(err);/*from w w w . j a v a2 s .c om*/ err.close(); try { arrayOutputStream.close(); } catch (IOException e1) { } return arrayOutputStream.toString(); }
From source file:Main.java
public static void appendOneline(String fileName, String oneline) { PrintWriter out = null;//ww w . java2 s . c o m try { out = new PrintWriter(new BufferedWriter(new FileWriter(fileName, true))); out.print(oneline + "\n"); } catch (IOException e) { e.printStackTrace(); } finally { if (out != null) { out.close(); } } }
From source file:Main.java
public static void clearLog() { File logFile = new File(Environment.getExternalStorageDirectory() + "/clr_log.file"); PrintWriter writer;/*from www . java 2s . co m*/ try { writer = new PrintWriter(logFile); writer.close(); } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
public static String getStackTraceString(Throwable t) { String value;//from w ww . j av a 2 s. c om if (t == null) { value = ""; } else { final StringWriter stackTrace = new StringWriter(); t.printStackTrace(new PrintWriter(stackTrace)); value = stackTrace.toString(); } return value; }
From source file:Main.java
public static String getStackTrace(Throwable aThrowable) { aThrowable.printStackTrace();//w w w . j a v a2s.c om final Writer result = new StringWriter(); final PrintWriter printWriter = new PrintWriter(result); aThrowable.printStackTrace(printWriter); return result.toString(); }