Search in sources :

Example 1 with CharArrayWriter

use of java.io.CharArrayWriter in project android_frameworks_base by ParanoidAndroid.

the class MobileDataStateTracker method toString.

@Override
public String toString() {
    final CharArrayWriter writer = new CharArrayWriter();
    final PrintWriter pw = new PrintWriter(writer);
    pw.print("Mobile data state: ");
    pw.println(mMobileDataState);
    pw.print("Data enabled: user=");
    pw.print(mUserDataEnabled);
    pw.print(", policy=");
    pw.println(mPolicyDataEnabled);
    return writer.toString();
}
Also used : CharArrayWriter(java.io.CharArrayWriter) PrintWriter(java.io.PrintWriter)

Example 2 with CharArrayWriter

use of java.io.CharArrayWriter in project android_frameworks_base by ParanoidAndroid.

the class NetworkStatsHistory method toString.

@Override
public String toString() {
    final CharArrayWriter writer = new CharArrayWriter();
    dump(new IndentingPrintWriter(writer, "  "), false);
    return writer.toString();
}
Also used : CharArrayWriter(java.io.CharArrayWriter) IndentingPrintWriter(com.android.internal.util.IndentingPrintWriter)

Example 3 with CharArrayWriter

use of java.io.CharArrayWriter in project hackpad by dropbox.

the class Context method getSourcePositionFromStack.

static String getSourcePositionFromStack(int[] linep) {
    Context cx = getCurrentContext();
    if (cx == null)
        return null;
    if (cx.lastInterpreterFrame != null) {
        Evaluator evaluator = createInterpreter();
        if (evaluator != null)
            return evaluator.getSourcePositionFromStack(cx, linep);
    }
    /**
         * A bit of a hack, but the only way to get filename and line
         * number from an enclosing frame.
         */
    CharArrayWriter writer = new CharArrayWriter();
    RuntimeException re = new RuntimeException();
    re.printStackTrace(new PrintWriter(writer));
    String s = writer.toString();
    int open = -1;
    int close = -1;
    int colon = -1;
    for (int i = 0; i < s.length(); i++) {
        char c = s.charAt(i);
        if (c == ':')
            colon = i;
        else if (c == '(')
            open = i;
        else if (c == ')')
            close = i;
        else if (c == '\n' && open != -1 && close != -1 && colon != -1 && open < colon && colon < close) {
            String fileStr = s.substring(open + 1, colon);
            if (!fileStr.endsWith(".java")) {
                String lineStr = s.substring(colon + 1, close);
                try {
                    linep[0] = Integer.parseInt(lineStr);
                    if (linep[0] < 0) {
                        linep[0] = 0;
                    }
                    return fileStr;
                } catch (NumberFormatException e) {
                // fall through
                }
            }
            open = close = colon = -1;
        }
    }
    return null;
}
Also used : CharArrayWriter(java.io.CharArrayWriter) PrintWriter(java.io.PrintWriter)

Example 4 with CharArrayWriter

use of java.io.CharArrayWriter in project hackpad by dropbox.

the class RhinoException method generateStackTrace.

private String generateStackTrace() {
    // Get stable reference to work properly with concurrent access
    CharArrayWriter writer = new CharArrayWriter();
    super.printStackTrace(new PrintWriter(writer));
    String origStackTrace = writer.toString();
    Evaluator e = Context.createInterpreter();
    if (e != null)
        return e.getPatchedStack(this, origStackTrace);
    return null;
}
Also used : CharArrayWriter(java.io.CharArrayWriter) PrintWriter(java.io.PrintWriter)

Example 5 with CharArrayWriter

use of java.io.CharArrayWriter in project NoHttp by yanzhenjie.

the class IOUtils method toCharArray.

public static char[] toCharArray(CharSequence input) throws IOException {
    CharArrayWriter output = new CharArrayWriter();
    write(input, output);
    return output.toCharArray();
}
Also used : CharArrayWriter(java.io.CharArrayWriter)

Aggregations

CharArrayWriter (java.io.CharArrayWriter)211 PrintWriter (java.io.PrintWriter)51 IOException (java.io.IOException)39 IndentingPrintWriter (com.android.internal.util.IndentingPrintWriter)21 Test (org.junit.Test)11 InputStreamReader (java.io.InputStreamReader)9 Map (java.util.Map)9 BufferedReader (java.io.BufferedReader)8 File (java.io.File)8 ArrayList (java.util.ArrayList)8 TitledBorder (javax.swing.border.TitledBorder)8 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)7 Graph (edu.cmu.tetrad.graph.Graph)7 Writable (groovy.lang.Writable)7 CharArrayReader (java.io.CharArrayReader)7 Reader (java.io.Reader)7 Date (java.util.Date)7 InputStream (java.io.InputStream)6 StringReader (java.io.StringReader)6 IKnowledge (edu.cmu.tetrad.data.IKnowledge)5