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();
}
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();
}
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;
}
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;
}
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();
}
Aggregations