I'm trying to make a Java program which calls some other software as a command from cmd, receives the output, and prints it in a Jframe. The problem is that when it prints there are some characters (Which seem to be just spaces) which become squares. I think these characters are not recognized correctly. The homsimpl command is just from CHOMP (Computational Homology Project).
I tried to remove all the HTML code from the Strings, the squared characters were still there. When I put System.out.println(s)
or System.out.println(Outp)
it prints correctly in the output, without the squared characters. I also tried to change the font, but with any font I tried to use, the squared characters were still squared in the JFrame. If I copy the output text and paste it to be in the JFrame the squared characters disappear, but I can't solve the problem like that.
The JFrame appears like this:
and the Output shows:
HOMSIMPL, ver. 0.01, 11/09/04. Copyright (C) 1997-2013 by Pawel Pilarczyk.
This is free software. No warranty. Consult 'license.txt' for details.
[Tech info: simpl 4, chain 12, addr 4, intgr 2.]
Reading simplices to X from 'Simplicial.sim'... 4 simplices read.
Collapsing faces in X... .. 0 removed, 14 left.
Creating the chain complex of X... .. Done.
Time used so far: 0.00 sec (0.000 min).
Computing the homology of X over the ring of integers...
Reducing D_2: 0 + 3 reductions made.
Reducing D_1: 3 + 0 reductions made.
H_0 = Z
H_1 = 0
H_2 = Z
Saving generators of X to 'Simplicial.txt'... Done.
Total time used: 0.02 sec (0.000 min).
[Press Ctrl-C to exit.]
Thank you for using this software. We appreciate your business.
A simplified version of my program follows:
import java.io.*;
import javax.swing.*;
public class Test {
public static void main(String[] args)
throws IOException {
PrintWriter Cod = new PrintWriter("Simplicial.sim");
Cod.println("{1,2,3}");
Cod.println("{1,2,4}");
Cod.println("{1,3,4}");
Cod.println("{2,3,4}");
Cod.close();
Process p = Runtime.getRuntime().exec("cmd /c \"homsimpl Simplicial.sim -g Simplicial.txt\"");
BufferedReader stdInput = new BufferedReader(new
InputStreamReader(p.getInputStream()));
BufferedReader stdError = new BufferedReader(new
InputStreamReader(p.getErrorStream()));
String s = null;
JFrame f = new JFrame();
JPanel pa = new JPanel();
JLabel la = new JLabel();
f.setSize(500, 500);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(pa);
String Outp="";
JScrollPane pane = new JScrollPane(pa);
pa.add(la);
f.setContentPane(pane);
f.setVisible(true);
while ((s = stdInput.readLine()) != null) {
Outp=Outp+"<br/>"+s;
la.setText("<html>"+Outp+"</html>");
System.out.println(s);
}
while ((s = stdError.readLine()) != null) {
System.out.println(s);
}
}
}