Article View: borland.public.jbuilder.java.language
Article #14600Re: Java HEX question
From: Johan Forsberg
Date: Wed, 18 Aug 1999 00:00
Date: Wed, 18 Aug 1999 00:00
27 lines
1485 bytes
1485 bytes
Shawn Clark <shawn@shift4.com> skrev i
diskussionsgruppsmeddelandet:7pcog1$2913@forums.borland.com...
> Just one more easy question...
>
> I have an instance where I am using the JavaComm library
>
> Here is an example of code that I am using to print to a little printer
that
> I have over here.
> Now, this printer has the ability to do special things like change ribbon
> color. Now, in order to do this, I can either send ASCII: DC2 or HEX: 12
>
> My question is, how can I use either of the methods in a stream?
>
>
> outputStream.write(tempStr.getBytes());
What I normally do is wrap my streams in a PrintWriter. The PrintWriter is
buffered (increases performance) and has print() and println() methods.
PrintWriter writer=new PrintWriter(outputStream, true);
writer.println("Hello World!");
writer.print(0x12);
writer.print("\u0012");
The last two rows are two ways of writing hex 12 to the stream.
Technical Details
Message-ID:
<7pdm9q$1875@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7pcog1$2913@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,8463e65b10f77f02 X-Google-Attributes: gidf74b3,public From: "Johan Forsberg" <jfo@SPAM_SPAM_EGGS_SPAMstmf.se> Subject: Re: Java HEX question Date: 1999/08/18 Message-ID: <7pdm9q$1875@forums.borland.com> X-Deja-AN: 514115202 References: <7pcog1$2913@forums.borland.com> X-Priority: 3 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal Newsgroups: borland.public.jbuilder.java.language