Java Utililty Methods Dump Stream

List of utility methods to do Dump Stream

Description

The list of methods to do Dump Stream are organized into topic(s).

Method

voiddumpStreamToFile(InputStream is, String filename)
Dump the input stream to the specified file.
FileOutputStream fos = null;
try {
    fos = new FileOutputStream(filename);
    dumpStreamToStream(is, fos);
} catch (Exception ex) {
    ex.printStackTrace();
} finally {
    close(fos);
...
voiddumpStreamToStream(InputStream is, OutputStream os)
Dump the input stream to the output stream.
byte ba[] = new byte[2048];
int numRead = 0;
try {
    numRead = is.read(ba);
    while (numRead > 0) {
        os.write(ba, 0, numRead);
        numRead = is.read(ba);
} catch (Exception ex) {
    ex.printStackTrace();
} finally {
    if (os != null)
        try {
            os.flush();
        } catch (Exception ex) {
    ;
voiddumpThreads(PrintStream ps)
dump Threads
int active = Thread.activeCount();
Thread threads[] = new Thread[active];
Thread.enumerate(threads);
for (int i = 0; i < active; i++) {
    ps.println(i + ": " + threads[i]);
voiddumpToFile(Object obj, OutputStream os)
dump To File
ObjectOutputStream oos = null;
try {
    oos = new ObjectOutputStream(os);
    oos.writeObject(obj);
    oos.close();
} catch (IOException e) {
    e.printStackTrace();