import java.util.*;
import java.io.*;
public class ScannerTest
{ public static void main(String[] args)
{ Integer[] it=new Integer[]{1,2,3,4,5,6,7,8,9,10};
String[] str=new String[]{"aaarong","money","abcdefg","memoey",
"enery","mmmmm","mybole","enneil",
"esneg","ksajfl"};
try{
FileWriter f=new FileWriter("Test.txt");
for(int i=0;i<it.length;i++)
{ f.write(str[i]);
f.write("=");
f.write(it[i]);
f.write('\n');
}
f.close();
FileReader fin=new FileReader("Test.txt");
Scanner s=new Scanner(fin);
while(s.hasNext())
{ if(s.hasNextInt())
{ int K=s.nextInt();
System.out.println(K);
}
else
{ String M=s.next();
System.out.println(M);
}
}
fin.close();
}catch(Exception e)
{ System.out.println("Error");
}
}
}
而编译后输出是