Code example for PrintStream

Methods: checkError

0
        String path = SNAPSHOT_DIR + "/" + name + "-" + startMillis + ".snapshot";
        long start = System.currentTimeMillis();
        OutputStream outputStream = null;
        try { 
            outputStream = new BufferedOutputStream(new FileOutputStream(path));
            PrintStream out = new PrintStream(outputStream);
            generateSnapshotHeader(name, packageInfo, out);
            if (out.checkError()) {
                throw new IOException();
            } 
            BinaryHprofWriter.write(samplingProfiler.getHprofData(), outputStream);
        } catch (IOException e) {
            Log.e(TAG, "Error writing snapshot to " + path, e);
            return; 
        } finally { 
            IoUtils.closeQuietly(outputStream);
        } 
        // set file readable to the world so that SamplingProfilerService 
        // can put it to dropbox 
        new File(path).setReadable(true, false);