public String myReadLine()throws IOException
{
StringBuilder sb = new StringBuilder();
int ch = 0;
while((ch=r.read())!=-1)
{
if(ch=='\r')
continue;
if(ch=='\n')
return sb.toString();
else
sb.append((char)ch);
}
if(sb.length()!=0)
return sb.toString();
return null;
}
------------------------------------------------------------
public static void main(String[] args) throws IOException
{
FileReader fr = new FileReader("d:\\ArrayTool.java");
char[] c = new char[1024];
int ch = 0;
while((ch=fr.read(c))!=-1)
{
System.out.print(new String(c,0,c.length));
}
fr.close();
}
弱弱的问一句这两个代码里的ch分别代表什么意思?
我的理解上面ch是字符!下面ch是个数!不知对不对!
求教 |
|