aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/modernjava/launch/util/TextIoUtils.java
blob: b7f82c065591e573694b8fc21236696a5e6d0ac4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package moe.nea.modernjava.launch.util;

import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintStream;

public class TextIoUtils {
    /**
     * Flush out the standard IO, without closing it. Works even after {@link System#setOut(PrintStream)} or similar has been called
     */
    public static void flushStdIO() {
        try {
            // These streams should not be closed. We just want to flush them out
            //noinspection resource
            new FileOutputStream(FileDescriptor.out).flush();
            //noinspection resource
            new FileOutputStream(FileDescriptor.err).flush();
        } catch (IOException ignored) {
        }
    }
}