Advertisement
|
This page contains an archived post to the Java Answers Forum made prior to February 25, 2002.
If you wish to participate in discussions, please visit the new
Artima Forums.
Message:
int -> char -> String (more tidy version)
Posted by Chin Loong on January 17, 2002 at 12:44 PM
serviceHistory=new String(""); InputStream in=new FileInputStream(f); int b,count=0; char[] ch=new char[255]; while (true) { b = in.read(); if (b == 10 || b == -1 || count == 255) { serviceHistory=serviceHistory.concat(new String(ch,0,count)); if (count!=255) serviceHistory=serviceHistory.concat("\n"); count=0; if(b == -1) break; } else { ch[count]=(char)b; count++; } } in.close();
mr. lecturer, please grade :p
Replies:
|