• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 224
  • Last Modified:

Read from the com port

I have used the method below to open and write to the com port.
I wonder if anybody can help me write a method which reads from the com port.
Please show some example code though I'm not very skilled in JAVA coding, yet :-)

       public void printCom1(String OutPrint)
       {
         if (OutPrint != "")
         {
            PrintWriter out = null;
            try
            {
               out = new PrintWriter(new BufferedWriter(new FileWriter("Com1")));
            }
            catch ( IOException e)
            {}
            out.print(OutPrint);
            out.flush();
            out.close();
       }
0
joy3
Asked:
joy3
1 Solution
 
joy3Author Commented:
I wonder how this will effect the platform independency.
0
 
mparekhCommented:
SUN has come out with a new API for Communications.
It is available for download at the Java Developer Connection.
This package has sample code to read/write Communication ports.
This package should solve your problem.

http://developer.javasoft.com
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now