Discussions
Categories
- 197.1K All Categories
- 2.5K Data
- 546 Big Data Appliance
- 1.9K Data Science
- 450.7K Databases
- 221.9K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 552 MySQL Community Space
- 479 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3.1K ORDS, SODA & JSON in the Database
- 555 SQLcl
- 4K SQL Developer Data Modeler
- 187.2K SQL & PL/SQL
- 21.3K SQL Developer
- 296.3K Development
- 17 Developer Projects
- 139 Programming Languages
- 293K Development Tools
- 110 DevOps
- 3.1K QA/Testing
- 646.1K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 158 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.2K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 19 Java Essentials
- 162 Java 8 Questions
- 86K Java Programming
- 81 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 466 LiveLabs
- 39 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 175 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 233 Portuguese
Problem with displaying data

860088
Member Posts: 10
Hello!
I am working on an application that is used to read serial port data and parse it.
The following problem arise:
When i print the data using
Thanks in advance!
Best Regards,
Dean
I am working on an application that is used to read serial port data and parse it.
The following problem arise:
When i print the data using
System.out.println("10.05.1108:12:19 1 11 00:00:02080012345 2 ");the program outputs the data in the correct way.
10.05.1108:12:19 1 11 00:00:02080012345 2but when i add the data to the GUI
gui.addText("10.05.1108:12:19 1 11 00:00:02080012345 2 ");the program outputs:
:10:.05:.110:8:::1:2::1:9 1 11 00:0:0::02:0:8:0:0:1:2:345 : : : : : : : : : 2 : : : : : : : : :Any idea on solving this problem?
Thanks in advance!
Best Regards,
Dean
Tagged:
Answers
-
dkocevski wrote:I'm pretty sure I could code an example that says 'it works for me', but then, I would be making many assumptions about your code, and I don't like guessing. For better help sooner, post an SSCCE.
..Any idea on solving this problem? -
-
Just guessing: CallLogRGUI expects the String given in it's <tt>addText(String text)</tt> method to have some structure and adds the additional colons (:) at positions it thinks they where usefull.
So please show the implementation of CallLogRGUI .
bye
TPD -
CallLogRGUI.java :
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * CallLogRGUI.java * * Created on 5.5.2011, 09:18: */ package calllogr; import java.io.*; /** * * @author Dean */ public class CallLogRGUI extends javax.swing.JFrame { /** Creates new form CallLogRGUI */ public CallLogRGUI() { initComponents(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { ScroolPane = new javax.swing.JScrollPane(); txtOutput = new javax.swing.JTextArea(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("CallLogR - Резерва ДКМ дооел"); addWindowListener(new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { formWindowClosing(evt); } }); txtOutput.setColumns(20); txtOutput.setRows(5); ScroolPane.setViewportView(txtOutput); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(ScroolPane, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(ScroolPane, javax.swing.GroupLayout.DEFAULT_SIZE, 278, Short.MAX_VALUE) .addContainerGap()) ); pack(); }// </editor-fold> private void formWindowClosing(java.awt.event.WindowEvent evt) { try{ // Create file FileWriter fstream = new FileWriter("C:/test/CDR.txt"); BufferedWriter out = new BufferedWriter(fstream); out.write(txtOutput.getText()); //Close the output stream out.close(); }catch (Exception e){//Catch exception if any System.err.println("Error: " + e.getMessage()); } } /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new CallLogRGUI().setVisible(true); } }); } public void addText(String s){ txtOutput.setText(txtOutput.getText()+":"+s); } // Variables declaration - do not modify private javax.swing.JScrollPane ScroolPane; private javax.swing.JTextArea txtOutput; // End of variables declaration }
-
I'd say the problem is
while (inputStream.available() > 0) { int numBytes = inputStream.read(readBuffer); }
where you are not waiting for a line to be completely red.
I'd sugest to use <tt>readLine()</tt> method of BufferedReader here.
bye
TPD -
I had a problem in parsing the string. Problem solved. Thank you all!
This discussion has been closed.