Skip to content

Commit

Permalink
implement #319
Browse files Browse the repository at this point in the history
  • Loading branch information
enridaga committed Nov 24, 2022
1 parent 3042362 commit a314b14
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintStream;
Expand Down Expand Up @@ -575,4 +576,22 @@ public static void main(String[] args) throws Exception {
logger.trace("[time] Process ends: {}", System.currentTimeMillis() - duration);
}
}

public static String callMain(String[] args) throws Exception {
// Thanks to: https://stackoverflow.com/a/8708357/1035608
// Create a stream to hold the output
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
// IMPORTANT: Save the old System.out!
PrintStream old = System.out;
// Tell Java to use your special stream
System.setOut(ps);
// Print some output: goes to your special stream
main(args);
// Put things back
System.out.flush();
System.setOut(old);
// Show what happened
return baos.toString();
}
}

0 comments on commit a314b14

Please sign in to comment.