您的位置:首页 > 其它

读入字符串,遇到某一字符结束读入

2012-05-15 16:36 253 查看
/**
* 读入字符串,遇到某一字符结束读入
* int.txt: 中国123美国abc日本;123
*/
import java.io.*;
class Test
{
public static void main(String[] args) throws IOException
{
FileReader in = new FileReader("in.txt");
int c;
StringBuffer sb = new StringBuffer();
c = in.read();
while( (c != ';') && (c != -1) )
{
sb.append((char)c);
c = in.read();
}
System.out.println(sb);
in.close();
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  string class c
相关文章推荐