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
Posted by Chin Loong on January 17, 2002 at 12:39 PM
this is a snippet of a code i used last time, a bit messy since i wrote it quite some time ago.. :p serviceHistory=new String(""); InputStream in=new FileInputStream(f); // out.write(new String("Service History :\n" + "Date : " + date.getText() + "\n").getBytes()); 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();
Replies:
|