use of java.io.BufferedWriter in project dex2jar by pxb1988.
the class DexWaveTest method toStd.
public static String toStd(DexClassNode expected) throws IOException {
StringWriter stringWriter = new StringWriter();
BufferedWriter bufferedWriter = new BufferedWriter(stringWriter);
BaksmaliDumpOut out = new BaksmaliDumpOut(bufferedWriter);
final BaksmaliDumper bs = new BaksmaliDumper(true, false);
bs.baksmaliClass(expected, out);
bufferedWriter.close();
return stringWriter.toString();
}
use of java.io.BufferedWriter in project weiciyuan by qii.
the class ExceptionHandler method uncaughtException.
public void uncaughtException(Thread thread, Throwable exception) {
final Date now = new Date();
final Writer result = new StringWriter();
final PrintWriter printWriter = new PrintWriter(result);
exception.printStackTrace(printWriter);
try {
String logDir = FileManager.getLogDir();
if (TextUtils.isEmpty(logDir)) {
return;
}
String filename = UUID.randomUUID().toString();
String path = logDir + File.separator + filename + ".stacktrace";
BufferedWriter write = new BufferedWriter(new FileWriter(path));
write.write("Package: " + CrashManagerConstants.APP_PACKAGE + "\n");
write.write("Version: " + CrashManagerConstants.APP_VERSION + "\n");
write.write("Android: " + CrashManagerConstants.ANDROID_VERSION + "\n");
write.write("Manufacturer: " + CrashManagerConstants.PHONE_MANUFACTURER + "\n");
write.write("Model: " + CrashManagerConstants.PHONE_MODEL + "\n");
write.write("Date: " + now + "\n");
write.write("\n");
write.write(result.toString());
write.flush();
write.close();
} catch (Exception another) {
} finally {
previousHandler.uncaughtException(thread, exception);
}
}
use of java.io.BufferedWriter in project platform_frameworks_base by android.
the class WifiApStress method tearDown.
@Override
protected void tearDown() throws Exception {
// write the total number of iterations into output file
mOutputWriter = new BufferedWriter(new FileWriter(new File(Environment.getExternalStorageDirectory(), OUTPUT_FILE)));
mOutputWriter.write(String.format("iteration %d out of %d\n", mLastIteration + 1, mTotalIterations));
mOutputWriter.flush();
mOutputWriter.close();
super.tearDown();
}
use of java.io.BufferedWriter in project platform_frameworks_base by android.
the class MultipartTest method testParts.
public void testParts() throws Exception {
StringBuffer filebuffer = new StringBuffer();
String filepartStr = "this is file part";
filebuffer.append(filepartStr);
File upload = File.createTempFile("Multipart", "test");
FileWriter outFile = new FileWriter(upload);
BufferedWriter out = new BufferedWriter(outFile);
try {
out.write(filebuffer.toString());
out.flush();
} finally {
out.close();
}
Part[] parts = new Part[3];
parts[0] = new StringPart("stringpart", "PART1!!");
parts[1] = new FilePart(upload.getName(), upload);
parts[2] = new StringPart("stringpart", "PART2!!");
MultipartEntity me = new MultipartEntity(parts);
ByteArrayOutputStream os = new ByteArrayOutputStream();
me.writeTo(os);
Header h = me.getContentType();
String boundry = EncodingUtils.getAsciiString(me.getMultipartBoundary());
StringBuffer contentType = new StringBuffer("multipart/form-data");
contentType.append("; boundary=");
contentType.append(boundry);
assertEquals("Multipart content type error", contentType.toString(), h.getValue());
final String CRLF = "\r\n";
StringBuffer output = new StringBuffer();
output.append("--");
output.append(boundry);
output.append(CRLF);
output.append("Content-Disposition: form-data; name=\"stringpart\"");
output.append(CRLF);
output.append("Content-Type: text/plain; charset=US-ASCII");
output.append(CRLF);
output.append("Content-Transfer-Encoding: 8bit");
output.append(CRLF);
output.append(CRLF);
output.append("PART1!!");
output.append(CRLF);
output.append("--");
output.append(boundry);
output.append(CRLF);
output.append("Content-Disposition: form-data; name=\"");
output.append(upload.getName());
output.append("\"; filename=\"");
output.append(upload.getName());
output.append("\"");
output.append(CRLF);
output.append("Content-Type: application/octet-stream; charset=ISO-8859-1");
output.append(CRLF);
output.append("Content-Transfer-Encoding: binary");
output.append(CRLF);
output.append(CRLF);
output.append(filepartStr);
output.append(CRLF);
output.append("--");
output.append(boundry);
output.append(CRLF);
output.append("Content-Disposition: form-data; name=\"stringpart\"");
output.append(CRLF);
output.append("Content-Type: text/plain; charset=US-ASCII");
output.append(CRLF);
output.append("Content-Transfer-Encoding: 8bit");
output.append(CRLF);
output.append(CRLF);
output.append("PART2!!");
output.append(CRLF);
output.append("--");
output.append(boundry);
output.append("--");
output.append(CRLF);
// System.out.print(output.toString());
assertEquals("Multipart content error", output.toString(), os.toString());
// System.out.print(os.toString());
}
use of java.io.BufferedWriter in project platform_frameworks_base by android.
the class VideoDumpView method onResume.
@Override
public void onResume() {
Log.d(TAG, "onResume");
mMediaPlayer = new MediaPlayer();
try {
mMediaPlayer.setDataSource(VideoDumpConfig.VIDEO_URI);
class RGBFilter implements FilenameFilter {
public boolean accept(File dir, String name) {
return (name.endsWith(VideoDumpConfig.IMAGE_SUFFIX));
}
}
File dump_dir = new File(VideoDumpConfig.ROOT_DIR);
File[] dump_files = dump_dir.listFiles(new RGBFilter());
for (File dump_file : dump_files) {
dump_file.delete();
}
File image_list = new File(VideoDumpConfig.ROOT_DIR + VideoDumpConfig.IMAGES_LIST);
image_list.delete();
mImageListWriter = new BufferedWriter(new FileWriter(image_list));
} catch (java.io.IOException e) {
Log.e(TAG, e.getMessage(), e);
}
queueEvent(new Runnable() {
public void run() {
mRenderer.setMediaPlayer(mMediaPlayer);
mRenderer.setImageListWriter(mImageListWriter);
}
});
super.onResume();
}
Aggregations