读入字符串,遇到某一字符结束读入
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(); } }
相关文章推荐
- atof跳过前面的空格字符,直到遇上数字或正负符号才开始做转换,而再遇到非数字或字符串结束时('\0')才结束转换
- 将一个字符串转换为一个整数,若遇到非数字字符则返回0
- sql语句实现返回某一字符串中出现某一字符的次数
- NSDate转NSString遇到异常字符时字符串被截断JSON解析失败
- (28)'c++:COMPLETE REFERENCE' 第一部分 第四章(数组和以空字符结束的字符串) 第三节
- 写一函数,实现用某一字符c 去填充字符串的左部(右部),使其长度为恰好为length
- c语言从键盘中输入一串字符串,将字符中的大写转化成小写字母,将小写字母转换成大写字母,以*号键结束
- 001_019 Python 检查字符串中的结束字符
- 我们在 web 应用开发过程中经常遇到输出某种编码的字符,如 iso8859-1 等,如何输出一个某种编码的字符串?
- scanf读入字符串与读入字符的区别
- 汇编程序:已知有一字符串STR,以'$'为结束标志,编写程序,把STR的内容复 制到NEW_STR中? 要求复制时(1)滤去所有非英文字符;(2)把大写字母变成小写;(3)统计新字符的长度放在NUM中
- idea Error:(1, 10) java: 需要class, interface或enum, 未结束的字符串文字,Error:(55, 136) java: 非法字符: \65533
- JAVA中将字符串按某一分隔符分隔为多个字符…
- (31)'c++:COMPLETE REFERENCE' 第一部分 第四章(数组和以空字符结束的字符串) 第六节
- java 从键盘读入一字符,循环打印输出,遇到字符9退出,可以根据不同输入执行不同任务
- 字符拷贝时字符串结束符'\0'很重要
- c++关于结尾遇到‘\n’或其他特殊字符结束读取的问题(个人总结,大神勿喷)
- Json数据字符串 反序列化对象时出现错误。遇到意外字符
- 学习笔记 - BufferedReader字符缓冲流从文件读入字符串
- json格式的字符串转为json对象遇到特殊字符问题解决