TestShiftPIR_E.java 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. package subprotocols;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.io.InputStreamReader;
  5. import java.util.Arrays;
  6. public class TestShiftPIR_E {
  7. public static void main(String[] args) {
  8. Runtime runTime = Runtime.getRuntime();
  9. Process process = null;
  10. String dir = System.getProperty("user.dir");
  11. String binDir = dir + "\\bin";
  12. String libs = dir + "\\lib\\*";
  13. try {
  14. process = runTime.exec("java -classpath " + binDir + ";" + libs + " ui.CLI -protocol shiftpir eddie");
  15. } catch (IOException e) {
  16. e.printStackTrace();
  17. }
  18. InputStream inputStream = process.getInputStream();
  19. InputStreamReader isr = new InputStreamReader(inputStream);
  20. InputStream errorStream = process.getErrorStream();
  21. InputStreamReader esr = new InputStreamReader(errorStream);
  22. System.out.println("STANDARD OUTPUT:");
  23. int n1;
  24. char[] c1 = new char[1024];
  25. try {
  26. while ((n1 = isr.read(c1)) > 0) {
  27. System.out.print(new String(Arrays.copyOfRange(c1, 0, n1)));
  28. }
  29. } catch (IOException e) {
  30. e.printStackTrace();
  31. }
  32. System.out.println("STANDARD ERROR:");
  33. int n2;
  34. char[] c2 = new char[1024];
  35. try {
  36. while ((n2 = esr.read(c2)) > 0) {
  37. System.err.print(new String(Arrays.copyOfRange(c2, 0, n2)));
  38. }
  39. } catch (IOException e) {
  40. e.printStackTrace();
  41. }
  42. }
  43. }