I'm trying to get a FIX message from the client side to server side, where I created a UI for the server. The only problem is that, when I try to output the message onto the textarea, it won't update, while the rest of the program work, such as the text fields will all properly update, when called. I have the action event put onto a button click.
I put the output of the message inside a while loop, does that affect the way it outputs?
problem area
String inputLine, outputLine;
try {
while ((inputLine = in.readLine()) != null)
{
System.out.println ("Server: " + inputLine);
tfFIXMsg.append( inputLine+ "\n\n\n");
action event
@Override
public void actionPerformed(ActionEvent evt) {
port = Integer.parseInt(tfPort.getText());
fileLocation = tfLocation.getText();
String csvName = fileLocation;
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(port);
}
catch (IOException e)
{
System.err.println("Could not listen on port: 57635.");
System.exit(1);
}
Socket clientSocket = null;
System.out.println ("Waiting for connection.....");
try {
clientSocket = serverSocket.accept();
}
catch (IOException e)
{
System.err.println("Accept failed.");
System.exit(1);
}
System.out.println ("Connection successful");
System.out.println ("Waiting for input.....");
PrintWriter out = null;
try {
out = new PrintWriter(clientSocket.getOutputStream(),
true);
} catch (IOException e) {
e.printStackTrace();
}
BufferedReader in = null;
try {
in = new BufferedReader(
new InputStreamReader( clientSocket.getInputStream()));
} catch (IOException e) {
e.printStackTrace();
}
String inputLine, outputLine;
try {
while ((inputLine = in.readLine()) != null)
{
System.out.println ("Server: " + inputLine);
tfFIXMsg.append( inputLine+ "\n\n\n");
if (inputLine.trim().equals("Bye.")) {
System.out.println("Exit program");
break;
}
Scanner input1 = new Scanner(new File(csvName));
Scanner input2 = new Scanner(new File(csvName));
Scanner input3 = new Scanner(new File(csvName));
Scanner input4 = new Scanner(new File(csvName));
String csvline = getCsvLineVal (getLocation34CSV(getTag34Value(Tag34Location(getTagCSV( parseFixMsg(inputLine ,inputLine))), getValueCSV( parseFixMsg(inputLine ,inputLine))), getVal34(input1, input2)), getCSVLine( input3, input4) );
outputLine = compareClientFixCSV( getTagCSV( parseFixMsg(inputLine ,inputLine)), getValueCSV(parseFixMsg(inputLine ,inputLine)), getCSVTag(csvline), getCSVValue(csvline));
out.println(outputLine);
tfCSVLine.setText(outputLine);
input1.close();
input2.close();
input3.close();
input4.close();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
out.close();
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
clientSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
try {
serverSocket.close();
} catch (IOException e) {
e.printStackTrace();
}
}
More Specifically
tfFIXMsg.append( inputLine+ "\n\n\n");