Writing ASCII character into serial port
<pre><code>Device manual said "Each record is terminated by ASCII(13) (&lt;CR&gt;)"
</code></pre>

<p>Sample message::</p>

<pre><code>H|\^&amp;|||LISHost9|||||TANGO4|||1|19991029132738&lt;CR&gt;

P|1||PatID01||Meier^Anna||19741001|F|||||SenderID01&lt;CR&gt;

O|1|SmplID1||^^^AB0+D||19991029132538|||||||||S||||||||||F&lt;CR&gt;

O|2|SmplID1||^^^Rhd||19991029132538|||||||||S||||||||||F&lt;CR&gt;

L|1|N&lt;CR&gt;
</code></pre>

<p>to write the above message into serial port of an Analyzer, I am using following read method.</p>

<pre><code>public String read() {
        String fileContent = "";
        if (hasFile()) {
            try {
                File file = files[0];               
                char buffer[] = new char[((int) file.length())];
                FileReader fileReader = new FileReader(file);
                fileReader.read(buffer);                
                fileReader.close();
                fileContent = new String(buffer);
            } catch (Exception e) {
                logger.error(e.getMessage(), e);
            }
        }

        return fileContent;
    }
</code></pre>

<p>write method::</p>

<pre><code>public void write2Port()throws IOException, InterruptedException{           
        DirectoryFetcher dr = new DirectoryFetcher();           
        if(dr.hasFile()){               
            String message = dr.read();
            try {

                outputStream.write(message.getBytes());                 
                System.out.println("writing message completed::");                  

                dr.delete();
            } catch (Exception e) {
                e.printStackTrace();
            }       

        }else{
            portWriter.sleep(1000);
        }       
    }
</code></pre>

<p>My question is that read message and write message approach is right or wrong.</p>

<p>If have any better approach ,please answer.</p>
