Originally posted by: Sherwin32
When I run my java-cplex program in Eclipse, the program generates all the solution data and prints them all into the console block.
My problem here is: How can I get the console messages and append them into the textArea of my user interface?
For now I have one imperfect way, which I found in the internet, to solve this problem:
/**************************************************************/
//(partial code)
OutputStream jtextOut;
jtextOut = new OutputStream()
{
final int BUFFER_LENGTH = 1024;
byte buf[] = new byte
BUFFER_LENGTH;
int pos = 0;
public void write(int b) throws IOException
{
buf
pos ++ = (byte)b;
if (pos >= BUFFER_LENGTH)
flush();
}
public void flush() throws IOException
{
if (pos >= BUFFER_LENGTH)
ta2.append(new String(buf));
else
ta2.append(new String(buf, 0, pos));
pos = 0;
}
};
System.setOut( new PrintStream(jtextOut, true));
/***************************************************************/
In this way, I can append the messages in the console into my textArea(in this case it'd be ta2)
But there's still a problem that all the messages are printed at once exactly when the computing has been terminated(due to out-of-memory problem).
What I need is to get the messages and print them instantaneously, instead of getting all of them in the end.
Can anyone understand my question? Sorry for the poor English.
#CPLEXOptimizers#DecisionOptimization