Re: [OT] Basic int/char conversion question

2009-01-13 Thread André Warnier
Hi. Christopher Schultz wrote: André, André Warnier wrote: an existing webapp reads from a socket connected to an external program. The input stream is created as follows : fromApp = socket.getInputStream(); The read is as follows : StringBuffer buf = new StringBuffer(2000); int ic; while((ic

Re: [OT] Basic int/char conversion question

2009-01-12 Thread Christopher Schultz
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 André, André Warnier wrote: > an existing webapp reads from a socket connected to an external program. > The input stream is created as follows : > fromApp = socket.getInputStream(); > The read is as follows : > StringBuffer buf = new StringBuffer(200

Re: [OT] Basic int/char conversion question

2009-01-02 Thread Ken Bowen
On Jan 2, 2009, at 7:39 AM, André Warnier wrote: Once again, as I believe Chuck once wrote, when one knows how to phrase the question, one probably has already 90% of the answer. Sometimes, posing the question solves the problem. More than once, thinking I was stuck, I set out to compose

Re: [OT] Basic int/char conversion question

2009-01-02 Thread André Warnier
Caldarale, Charles R wrote: From: Konstantin Kolinko [mailto:knst.koli...@gmail.com] Subject: Re: [OT] Basic int/char conversion question reset() is not implemented in InputStreamReader Quite correct; sorry - the revised code would be this: import java.io.ByteArrayInputStream; import

RE: [OT] Basic int/char conversion question

2009-01-01 Thread Caldarale, Charles R
> From: Konstantin Kolinko [mailto:knst.koli...@gmail.com] > Subject: Re: [OT] Basic int/char conversion question > > reset() is not implemented in InputStreamReader Quite correct; sorry - the revised code would be this: import java.io.ByteArrayInputStream; import java.io.Input

Re: [OT] Basic int/char conversion question

2009-01-01 Thread Konstantin Kolinko
2009/1/2 Caldarale, Charles R : >> From: Len Popp [mailto:len.p...@gmail.com] >> Subject: Re: [OT] Basic int/char conversion question >> >> If there's an easy way to convert a single character, >> someone please point it out. > > Not particularly easy,

RE: [OT] Basic int/char conversion question

2009-01-01 Thread Caldarale, Charles R
> From: Len Popp [mailto:len.p...@gmail.com] > Subject: Re: [OT] Basic int/char conversion question > > If there's an easy way to convert a single character, > someone please point it out. Not particularly easy, but this should work: import java.io.ByteArra

RE: [OT] Basic int/char conversion question

2009-01-01 Thread Caldarale, Charles R
> From: André Warnier [mailto:a...@ice-sa.com] > Subject: Re: [OT] Basic int/char conversion question > > Suppose I do this : > > String knownEncoding = "ISO-8859-1"; // or "ISO-8859-2" > InputStreamReader fromApp; > fromApp = = new InputStreamReade

RE: [OT] Basic int/char conversion question

2009-01-01 Thread Caldarale, Charles R
> From: André Warnier [mailto:a...@ice-sa.com] > Subject: Re: [OT] Basic int/char conversion question > > I must say that I find it a bit curious that Java does not > have an easy out-of-the-box method to convert a byte to a > char, with a character filter specifier. This woul

Re: [OT] Basic int/char conversion question

2009-01-01 Thread André Warnier
To Konstantin and all the others who have responded, many thanks for all the tips, specially since this was quite a bit off-topic. I need some time to digest the tips though, and choose the best way according to the code that was dumped in my lap. I must say that I find it a bit curious that J

Re: [OT] Basic int/char conversion question

2009-01-01 Thread Konstantin Kolinko
2009/1/1 André Warnier : > Hi. > > This has nothing specific to Tomcat, it's just a problem I'm having as a > non-java expert in modifying an exiting webapp. > I hope someone on this list can answer quickly, or send me to the > appropriate place to find out. I have tried to find, but get somewhat

RE: [OT] Basic int/char conversion question

2009-01-01 Thread Martin Gainty
: [OT] Basic int/char conversion question > > On Thu, Jan 1, 2009 at 14:39, André Warnier wrote: > > I note with satisfaction that I'm not the only one laboring away on this > > day-after, but you're just all going a bit too fast for me and my growing > > but s

Re: [OT] Basic int/char conversion question

2009-01-01 Thread Len Popp
On Thu, Jan 1, 2009 at 14:39, André Warnier wrote: > I note with satisfaction that I'm not the only one laboring away on this > day-after, but you're just all going a bit too fast for me and my growing > but still limited Java knowledge. No hang-over here. :-) > In other words, in order to keep

Re: [OT] Basic int/char conversion question

2009-01-01 Thread André Warnier
Caldarale, Charles R wrote: From: Len Popp [mailto:len.p...@gmail.com] Subject: Re: [OT] Basic int/char conversion question I note with satisfaction that I'm not the only one laboring away on this day-after, but you're just all going a bit too fast for me and my growing but sti

RE: [OT] Basic int/char conversion question

2009-01-01 Thread Caldarale, Charles R
> From: Len Popp [mailto:len.p...@gmail.com] > Subject: Re: [OT] Basic int/char conversion question > > I didn't mean to change the input stream at all, just change "buf" > from a StringBuffer to a ByteBuffer, then create a String with the > correct byte-to-charact

Re: [OT] Basic int/char conversion question

2009-01-01 Thread Len Popp
On Thu, Jan 1, 2009 at 12:09, Caldarale, Charles R wrote: >> From: Len Popp [mailto:len.p...@gmail.com] >> Subject: Re: [OT] Basic int/char conversion question >> >> Another option: Read the bytes into a ByteBuffer, then convert >> the bytes into a string. You c

RE: [OT] Basic int/char conversion question

2009-01-01 Thread Caldarale, Charles R
> From: Len Popp [mailto:len.p...@gmail.com] > Subject: Re: [OT] Basic int/char conversion question > > Another option: Read the bytes into a ByteBuffer, then convert > the bytes into a string. You can tell the String constructor > which charset to use. That would seem to

Re: [OT] Basic int/char conversion question

2009-01-01 Thread Len Popp
On Thu, Jan 1, 2009 at 11:13, André Warnier wrote: > Hi. > > This has nothing specific to Tomcat, it's just a problem I'm having as a > non-java expert in modifying an exiting webapp. > I hope someone on this list can answer quickly, or send me to the > appropriate place to find out. I have tried

RE: [OT] Basic int/char conversion question

2009-01-01 Thread Caldarale, Charles R
> From: André Warnier [mailto:a...@ice-sa.com] > Subject: [OT] Basic int/char conversion question > I cannot change the InputStream into something else Actually, I think you can. If you wrapper the InputStream with an InputStreamReader specifying the desired character set, the rest of

[OT] Basic int/char conversion question

2009-01-01 Thread André Warnier
Hi. This has nothing specific to Tomcat, it's just a problem I'm having as a non-java expert in modifying an exiting webapp. I hope someone on this list can answer quickly, or send me to the appropriate place to find out. I have tried to find, but get somewhat lost in the Java docs. Problem