Added STDERR to pure java payload, cleaned up user's view.

git-svn-id: file:///home/svn/framework3/trunk@8308 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
natron
2010-01-28 22:53:36 +00:00
parent 70c0cb7530
commit 69ad365b46
14 changed files with 83 additions and 24 deletions
+54
View File
@@ -0,0 +1,54 @@
// Based on the example from http://www.java2s.com/Code/Java/JDK-6/CompilingfromMemory.htm
package javaCompile;
import java.io.PrintStream;
import java.io.FilterOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.OutputStream;
import java.io.IOException;
import sun.security.tools.KeyTool;
import sun.security.tools.JarSigner;
public class SignJar {
static PrintStream filteredstream =
new PrintStream(
new FilteredStream(
new ByteArrayOutputStream()));
public static void KeyToolMSF( String[] args ) {
try {
RedirectStd();
KeyTool.main( args );
} catch( Exception ex ) { ex.printStackTrace(); }
}
public static void JarSignerMSF( String[] args ) {
try {
RedirectStd();
JarSigner.main( args );
} catch( Exception ex ) { ex.printStackTrace(); }
}
private static void RedirectStd() {
try {
System.setOut( filteredstream );
System.setErr( filteredstream );
} catch( Exception ex ) { ex.printStackTrace(); }
}
static class FilteredStream extends FilterOutputStream {
public FilteredStream( OutputStream aStream ) { super ( aStream ); }
public void write( byte b[] ) throws IOException {
String aString = new String( b );
// Do stuff with the output.
}
public void write( byte b[], int off, int len) throws IOException {
String aString = new String( b, off, len );
// Do stuff with the output.
}
}
}