Search in sources :

Example 31 with BufferedWriter

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();
}
Also used : StringWriter(java.io.StringWriter) BaksmaliDumper(com.googlecode.d2j.smali.BaksmaliDumper) BaksmaliDumpOut(com.googlecode.d2j.smali.BaksmaliDumpOut) BufferedWriter(java.io.BufferedWriter)

Example 32 with BufferedWriter

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);
    }
}
Also used : StringWriter(java.io.StringWriter) FileWriter(java.io.FileWriter) Date(java.util.Date) PrintWriter(java.io.PrintWriter) BufferedWriter(java.io.BufferedWriter) StringWriter(java.io.StringWriter) FileWriter(java.io.FileWriter) Writer(java.io.Writer) PrintWriter(java.io.PrintWriter) BufferedWriter(java.io.BufferedWriter)

Example 33 with BufferedWriter

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();
}
Also used : FileWriter(java.io.FileWriter) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Example 34 with BufferedWriter

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());
}
Also used : Header(org.apache.http.Header) FileWriter(java.io.FileWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) File(java.io.File) BufferedWriter(java.io.BufferedWriter)

Example 35 with BufferedWriter

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();
}
Also used : FilenameFilter(java.io.FilenameFilter) FileWriter(java.io.FileWriter) IOException(java.io.IOException) File(java.io.File) MediaPlayer(android.media.MediaPlayer) BufferedWriter(java.io.BufferedWriter)

Aggregations

BufferedWriter (java.io.BufferedWriter)1723 IOException (java.io.IOException)824 FileWriter (java.io.FileWriter)801 File (java.io.File)718 OutputStreamWriter (java.io.OutputStreamWriter)654 FileOutputStream (java.io.FileOutputStream)313 BufferedReader (java.io.BufferedReader)242 Writer (java.io.Writer)157 InputStreamReader (java.io.InputStreamReader)143 PrintWriter (java.io.PrintWriter)137 ArrayList (java.util.ArrayList)114 Test (org.junit.Test)109 FileNotFoundException (java.io.FileNotFoundException)108 FileReader (java.io.FileReader)98 Path (org.apache.hadoop.fs.Path)90 OutputStream (java.io.OutputStream)79 InputStream (java.io.InputStream)67 Date (java.util.Date)64 Path (java.nio.file.Path)63 FileInputStream (java.io.FileInputStream)59