Labguide on Windows


Subject: Labguide on Windows
From: Karl Lieberherr (lieber@ccs.neu.edu)
Date: Sun Oct 29 2000 - 12:13:58 EST


This is of interest to DemeterJ Windows users.
An interesting lesson on how to write platform-independent
Java code.

-- Karl L.

>From dougo@ccs.neu.edu Sun Oct 29 10:21:47 2000
>From: Doug Orleans <dougo@ccs.neu.edu>
>Date: Sun, 29 Oct 2000 10:21:44 -0500 (EST)
>To: Bud and Lori Grise <blgrise@mediaone.net>
>Cc: lieber@ccs.neu.edu, johan@ccs.neu.edu, stelios@ccs.neu.edu,
> wupc@ccs.neu.edu
>Subject: Re: Labguide change
>X-Face: (4D-osoq?}7M3\EgvbWKo<JkN/8h)A`1b^S1[8/OtYE1A61B!AOmH#YD+{HKhr7}@8gMv~.
> tsxTzT"g.oP0dTl!q
>Mime-Version: 1.0 (generated by tm-edit 7.108)
>
>Bud and Lori Grise writes:
> > Hi Doug,
> >
> > I forgot to mention this yesterday. I had to make a
> > small change to the labguide to get it to work under
> > windows.
> >
> > There are three places in LibrarySystem.beh where input
> > is read from the command line using
> > c = System.in.read(keyword)
> >
> > After this there is a line:
> > c = c - 1; // to strip the trailing return!
> >
> > I had to change this to:
> > c = c - 2; // to strip the trailing return!
> >
> > to work with the CR/LF terminator used by windows.
>
>Thanks for pointing this out.
>
> > I haven't used java for a while, but I remember that
> > there is an idiom for a host-independent way to read
> > file input so adjustments like these aren't needed.
> > I don't recall exactly what it is -- a nesting of
> > inputBufferedReader with some other classes I think.
>
>Yep, the idiom is:
>
> BufferedReader in
> = new BufferedReader(new InputStreamReader(System.in));
>
>and then you can use in.readLine() to get a line of input without the
>newline.
>
>Johan, care to fix the lab guide code?
>



This archive was generated by hypermail 2b28 : Sun Oct 29 2000 - 12:15:26 EST