Discovering available comm ports

From Rxtx

(Difference between revisions)
Jump to: navigation, search
(Restoring after spambot damage)
m
Line 1: Line 1:
-
This code snippet shows how to iretrive the available comms ports on your computer. A CommPort is available if it is not being used by another application. Note the differrence between the two examples is that the version for JDK 5.0 up uses [http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html generics]:
+
[http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=98 lisinopril] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=118 prozac online] [http://wc1.worldcrossing.com/WebX/.1de60a1e order flexeril] [http://wc1.worldcrossing.com/WebX/.1de60a35 free verizon ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/nextelringtones_3485.htm free nextel ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3695 carisoprodol online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=241 sony ericsson ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3723 motorola ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30318 diethylpropion online] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30253 norco online] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30350 free sagem ringtones] [http://library.cshl.edu/wp/vb/member.php?u=1372 free mp3 ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a1d free cingular ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=168 cheap celexa] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=221 vicodin online] [http://library.cshl.edu/wp/vb/member.php?u=1350 order meridia] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30363 free sony ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=202 nokia ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=84 cheap diethylpropion] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3716 buy diethylpropion] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=233 free sonyericsson ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30266 lorazepam online] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/ultracet_2738.htm ultracet online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=230 verizon ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3738 online xanax] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=83 didrex online] [http://library.cshl.edu/wp/vb/member.php?u=1343 carisoprodol online] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30365 mtv ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/freeringtones_8902.htm free ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3696 fioricet] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=136 cheap ultram] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/norco_532.htm norco online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3766 free music ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=170 free cingular ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=90 hgh online] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/propecia_2137.htm propecia online] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/ambien_7869.htm buy ambien] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3750 cheap didrex] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=189 lipitor] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=139 viagra online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3699 meridia online] [http://students.hsc.unt.edu/housing/item.cfm?type=2851 carisoprodol online] [http://students.hsc.unt.edu/housing/item.cfm?type=2918 free cool ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30316 vigrx online] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/verizonringtones_8798.htm verizon ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30330 free nokia ringtones] [http://wc1.worldcrossing.com/WebX/.1de609de but alprazolam] [http://wc1.worldcrossing.com/WebX/.1de609e5 free cool ringtones] [http://library.cshl.edu/wp/vb/member.php?u=1359 ambien online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=82 buy diazepam] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=206 cheap pharmacy online] [http://users.wpi.edu/~dance/blahdocs/uploads/nokiaringtones_4263.htm free nokia ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3741 cheap viagra] [http://library.cshl.edu/wp/vb/member.php?u=1382 free cingular ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2905 free motorola ringtones] [http://library.cshl.edu/wp/vb/member.php?u=1358 cheap hydrocodone] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30309 celexa online] [http://users.wpi.edu/~dance/blahdocs/uploads/nexium_6814.htm cheap nexium] [http://library.cshl.edu/wp/vb/member.php?u=1363 buy cyclobenzaprine] [http://wc1.worldcrossing.com/WebX/.1de60a1b free music ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2914 free sony ericsson ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3729 free mono ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3734 sony ringtones] [http://wc1.worldcrossing.com/WebX/.1de609f9 norco online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=97 lipitor online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3747 xenical] [http://users.wpi.edu/~dance/blahdocs/uploads/ultram_1401.htm ultram online] [http://students.hsc.unt.edu/housing/item.cfm?type=2849 cheap valium] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=85 free ericsson ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2877 cheap prozac] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3743 cheap vicodin] [http://library.cshl.edu/wp/vb/member.php?u=1388 cheap fioricet] [http://students.hsc.unt.edu/housing/item.cfm?type=2854 cheap ultram] [http://wc1.worldcrossing.com/WebX/.1de60a21 paxil online] [http://library.cshl.edu/wp/vb/member.php?u=1368 nokia ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3754 celexa] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3717 order hgh] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=197 mp3 ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2882 zoloft online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3752 albuterol online] [http://students.hsc.unt.edu/housing/item.cfm?type=2862 buy vicodin] [http://library.cshl.edu/wp/vb/member.php?u=1378 free sprint ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30244 cheap diazepam] [http://wc1.worldcrossing.com/WebX/.1de609f3 midi ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a16 levitra] [http://users.wpi.edu/~dance/blahdocs/uploads/ativan_8101.htm cheap ativan] [http://wc1.worldcrossing.com/WebX/.1de609fd punk ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=95 kyocera ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=215 buy zoloft] [http://students.hsc.unt.edu/housing/item.cfm?type=2904 real ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=207 xanax online] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/fioricet_7129.htm cheap fioricet] [http://students.hsc.unt.edu/housing/item.cfm?type=2920 free midi ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=182 free funny ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/vicodin_8272.htm vicodin online] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30356 cool ringtones] [http://library.cshl.edu/wp/vb/member.php?u=1369 free free ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2867 cheap hydrocodone] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3770 alltel ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3703 cheap hydrocodone] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3724 sprint ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=79 cheap clonazepam] [http://students.hsc.unt.edu/housing/item.cfm?type=2896 zyban online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=132 cheap tenuate] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=147 zoloft online] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30280 propecia online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=194 free midi ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3759 flexeril online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=213 cheap prozac] [http://wc1.worldcrossing.com/WebX/.1de609df cheap ambien] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/viagra_2557.htm cheap viagra] [http://students.hsc.unt.edu/housing/item.cfm?type=2902 nextel ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=117 order propecia] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=172 but clonazepam] [http://students.hsc.unt.edu/housing/item.cfm?type=2856 cheap cialis] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3720 free tracfone ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=143 wwe ringtones] [http://users.wpi.edu/~dance/blahdocs/uploads/wellbutrin_1044.htm buy wellbutrin] [http://students.hsc.unt.edu/housing/item.cfm?type=2926 jazz ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2876 buy didrex] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=116 free polyphonic ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a2e cheap xanax] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/nokiaringtones_9955.htm nokia ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/polyphonicringtones_8614.htm polyphonic ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=88 free free ringtones] [http://users.wpi.edu/~dance/blahdocs/uploads/valium_3.htm valium online] [http://wc1.worldcrossing.com/WebX/.1de60a31 buy zanaflex] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30245 cialis] [http://users.wpi.edu/~dance/blahdocs/uploads/cialis_7892.htm cheap cialis] [http://students.hsc.unt.edu/housing/item.cfm?type=2885 cheap tenuate] [http://students.hsc.unt.edu/housing/item.cfm?type=2906 free samsung ringtones] [http://users.wpi.edu/~dance/blahdocs/uploads/xanax_3394.htm cheap xanax] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=122 buy rivotril] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3731 free sharp ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30312 cheap ortho] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30230 cheap adipex] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3712 lipitor] [http://wc1.worldcrossing.com/WebX/.1de60a30 cheap xenical] [http://wc1.worldcrossing.com/WebX/.1de60a1a mtv ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/wellbutrin_1082.htm wellbutrin online] [http://wc1.worldcrossing.com/WebX/.1de60a23 polyphonic ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=115 phentermine online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=106 mtv ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a06 tenuate online] [http://users.wpi.edu/~dance/blahdocs/uploads/motorolaringtones_4301.htm free motorola ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3775 jazz ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3721 mp3 ringtones] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30338 free motorola ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=218 free qwest ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=145 xenical online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=239 cheap sildenafil] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3765 free samsung ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=80 free cool ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/levitra_8223.htm online levitra] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/nexium_2418.htm buy nexium] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/didrex_2512.htm didrex online] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=180 flexeril] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3718 hoodia online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=78 clomid] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/motorolaringtones_6710.htm motorola ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2880 albuterol online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=72 cheap ambien] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/meridia_7674.htm cheap meridia] [http://users.wpi.edu/~dance/blahdocs/uploads/viagra_3820.htm viagra online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3730 free punk ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=237 samsung ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=2694 valium online] [http://wc1.worldcrossing.com/WebX/.1de60a0a vicodin] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30235 soma online] [http://wc1.worldcrossing.com/WebX/.1de60a04 free sonyericsson ringtones] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=114 pharmacy online online] [http://users.wpi.edu/~dance/blahdocs/uploads/propecia_4184.htm cheap propecia] [http://wc1.worldcrossing.com/WebX/.1de60a00 cheap rivotril] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=187 kyocera ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a0f cheap cialis] [http://students.hsc.unt.edu/housing/item.cfm?type=2848 cheap soma] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/sonyericssonringtones_2032.htm sonyericsson ringtones] [http://users.wpi.edu/~dance/blahdocs/uploads/didrex_7351.htm didrex] [http://users.wpi.edu/~dance/blahdocs/uploads/ultracet_6057.htm ultracet online] [http://users.wpi.edu/~dance/blahdocs/uploads/hydrocodone_7117.htm hydrocodone online] [http://students.hsc.unt.edu/housing/item.cfm?type=2879 clomid online] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30366 jazz ringtones] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/cyclobenzaprine_72.htm cyclobenzaprine online] [http://library.cshl.edu/wp/vb/member.php?u=1340 cheap soma] [http://library.cshl.edu/wp/vb/member.php?u=1379 free music ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=222 vigrx online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3704 lorazepam online] [http://www.ees.ufl.edu/alumni/forums.asp?ForumId=5&TopicId=86 fioricet online] [http://students.hsc.unt.edu/housing/item.cfm?type=2863 alprazolam online] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3771 cool ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3707 nexium online] [http://www.colorado.edu/studentgroups/backcountryclub/blahdocs/uploads/mpringtones_1668.htm mp3 ringtones] [http://itcweb.ecsu.edu/portal/forums.asp?ForumId=13&TopicId=190 lisinopril online] [http://library.cshl.edu/wp/vb/member.php?u=1373 nextel ringtones] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=15&tid=3761 free free ringtones] [http://wc1.worldcrossing.com/WebX/.1de60a32 online zoloft] [http://www.ovu.edu/community/toast.asp?sub=show&action=posts&fid=5&tid=3722 qwest ringtones] [http://students.hsc.unt.edu/housing/item.cfm?type=2853 fioricet online] [http://users.wpi.edu/~dance/blahdocs/uploads/xenical_848.htm cheap xenical] [http://www.e.kth.se/cgi-bin/esekt/discussion?command=read&discussionid=4&id=30339 samsung ringtones] This code snippet shows how to iretrive the available comms ports on your computer. A CommPort is available if it is not being used by another application. Note the differrence between the two examples is that the version for JDK 5.0 up uses [http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html generics]:
<b>JDK <= 1.4</b>
<b>JDK <= 1.4</b>
Line 19: Line 19:
                 } catch (PortInUseException e) {
                 } catch (PortInUseException e) {
                     if (log.isInfoEnabled()) {
                     if (log.isInfoEnabled()) {
-
                         log.info("Port, " + com.getName() + ", is in use.");
+
                         log.info("Port, "   com.getName()   ", is in use.");
                     }
                     }
                 } catch (Exception e) {
                 } catch (Exception e) {
                     if (log.isErrorEnabled()) {
                     if (log.isErrorEnabled()) {
-
                         log.error("Failed to open port " + com.getName(), e);
+
                         log.error("Failed to open port "   com.getName(), e);
                     }
                     }
                 }
                 }
Line 50: Line 50:
                 } catch (PortInUseException e) {
                 } catch (PortInUseException e) {
                     if (log.isInfoEnabled()) {
                     if (log.isInfoEnabled()) {
-
                         log.info("Port, " + com.getName() + ", is in use.");
+
                         log.info("Port, "   com.getName()   ", is in use.");
                     }
                     }
                 } catch (Exception e) {
                 } catch (Exception e) {
                     if (log.isErrorEnabled()) {
                     if (log.isErrorEnabled()) {
-
                         log.error("Failed to open port " + com.getName(), e);
+
                         log.error("Failed to open port "   com.getName(), e);
                     }
                     }
                 }
                 }

Revision as of 06:16, 20 July 2007

lisinopril prozac online order flexeril free verizon ringtones free nextel ringtones carisoprodol online sony ericsson ringtones motorola ringtones diethylpropion online norco online free sagem ringtones free mp3 ringtones free cingular ringtones cheap celexa vicodin online order meridia free sony ringtones nokia ringtones cheap diethylpropion buy diethylpropion free sonyericsson ringtones lorazepam online ultracet online verizon ringtones online xanax didrex online carisoprodol online mtv ringtones free ringtones fioricet cheap ultram norco online free music ringtones free cingular ringtones hgh online propecia online buy ambien cheap didrex lipitor viagra online meridia online carisoprodol online free cool ringtones vigrx online verizon ringtones free nokia ringtones but alprazolam free cool ringtones ambien online buy diazepam cheap pharmacy online free nokia ringtones cheap viagra free cingular ringtones free motorola ringtones cheap hydrocodone celexa online cheap nexium buy cyclobenzaprine free music ringtones free sony ericsson ringtones free mono ringtones sony ringtones norco online lipitor online xenical ultram online cheap valium free ericsson ringtones cheap prozac cheap vicodin cheap fioricet cheap ultram paxil online nokia ringtones celexa order hgh mp3 ringtones zoloft online albuterol online buy vicodin free sprint ringtones cheap diazepam midi ringtones levitra cheap ativan punk ringtones kyocera ringtones buy zoloft real ringtones xanax online cheap fioricet free midi ringtones free funny ringtones vicodin online cool ringtones free free ringtones cheap hydrocodone alltel ringtones cheap hydrocodone sprint ringtones cheap clonazepam zyban online cheap tenuate zoloft online propecia online free midi ringtones flexeril online cheap prozac cheap ambien cheap viagra nextel ringtones order propecia but clonazepam cheap cialis free tracfone ringtones wwe ringtones buy wellbutrin jazz ringtones buy didrex free polyphonic ringtones cheap xanax nokia ringtones polyphonic ringtones free free ringtones valium online buy zanaflex cialis cheap cialis cheap tenuate free samsung ringtones cheap xanax buy rivotril free sharp ringtones cheap ortho cheap adipex lipitor cheap xenical mtv ringtones wellbutrin online polyphonic ringtones phentermine online mtv ringtones tenuate online free motorola ringtones jazz ringtones mp3 ringtones free motorola ringtones free qwest ringtones xenical online cheap sildenafil free samsung ringtones free cool ringtones online levitra buy nexium didrex online flexeril hoodia online clomid motorola ringtones albuterol online cheap ambien cheap meridia viagra online free punk ringtones samsung ringtones valium online vicodin soma online free sonyericsson ringtones pharmacy online online cheap propecia cheap rivotril kyocera ringtones cheap cialis cheap soma sonyericsson ringtones didrex ultracet online hydrocodone online clomid online jazz ringtones cyclobenzaprine online cheap soma free music ringtones vigrx online lorazepam online fioricet online alprazolam online cool ringtones nexium online mp3 ringtones lisinopril online nextel ringtones free free ringtones online zoloft qwest ringtones fioricet online cheap xenical samsung ringtones This code snippet shows how to iretrive the available comms ports on your computer. A CommPort is available if it is not being used by another application. Note the differrence between the two examples is that the version for JDK 5.0 up uses generics:

JDK <= 1.4

   /**
     * @return    A HashSet containing the CommPortIdentifier for all serial ports that are not currently being used.
     */
    public static HashSet getAvailableSerialPorts() {
        HashSet h = new HashSet();
        Enumeration thePorts = CommPortIdentifier.getPortIdentifiers();
        while (thePorts.hasMoreElements()) {
            CommPortIdentifier com = (CommPortIdentifier) thePorts.nextElement();
            switch (com.getPortType()) {
            case CommPortIdentifier.PORT_SERIAL:
                try {
                    CommPort thePort = com.open("CommUtil", 50);
                    thePort.close();
                    h.add(com);
                } catch (PortInUseException e) {
                    if (log.isInfoEnabled()) {
                        log.info("Port, "   com.getName()   ", is in use.");
                    }
                } catch (Exception e) {
                    if (log.isErrorEnabled()) {
                        log.error("Failed to open port "   com.getName(), e);
                    }
                }
            }
        }
        return h;
    }

JDK >= 5.0

   /**
     * @return    A HashSet containing the CommPortIdentifier for all serial ports that are not currently being used.
     */
    public static HashSet<CommPortIdentifier> getAvailableSerialPorts() {
        HashSet<CommPortIdentifier> h = new HashSet<CommPortIdentifier>();
        Enumeration thePorts = CommPortIdentifier.getPortIdentifiers();
        while (thePorts.hasMoreElements()) {
            CommPortIdentifier com = (CommPortIdentifier) thePorts.nextElement();
            switch (com.getPortType()) {
            case CommPortIdentifier.PORT_SERIAL:
                try {
                    CommPort thePort = com.open("CommUtil", 50);
                    thePort.close();
                    h.add(com);
                } catch (PortInUseException e) {
                    if (log.isInfoEnabled()) {
                        log.info("Port, "   com.getName()   ", is in use.");
                    }
                } catch (Exception e) {
                    if (log.isErrorEnabled()) {
                        log.error("Failed to open port "   com.getName(), e);
                    }
                }
            }
        }
        return h;
    }
Personal tools