回复 2楼 付政委
import java.util.Scanner;
import *;
public class basicType {
public static void main(String[] args) throws IOException {
String s1,s2;
s1="Hellow,how are you?";
s2="Hellow,how are you?";
if(s1.equals(s2))
System.out.println(s1);
long Long=99999;
int sum=0,i;
String s3=" ";
Scanner input=new Scanner(System.in);
System.out.println("输入一些整数 以0结束。");
do
{
try{
i=input.nextInt();
}
catch(Exception e)
{
s3=input.next();
i=1;
continue;
}
sum+=i;
}while(i!=0);
System.out.println(sum);
File f1=new File("E:\\2010javazhw\\java编程文件目录\\test.txt");
FileWriter fw=new FileWriter(f1,true);
fw.write(sum);
fw.write('f');
fw.write(s1);
fw.write(Long);
fw.close();
int k;
long l_1;
String st;
char ch;
FileReader fr=new FileReader(f1);
k=fr.read();
System.out.println(k);
ch=(char)fr.read();
System.out.print(ch);
//st=fr.read();
}
}
顺便问一下,为何 一定要抛出异常?详细点,谢谢,还有就是 Filereader 如何才能 读 一长串字符?