日期:2014-05-20 浏览次数:20737 次
import java.io.*; public class Welcome { public static void main(String args[])throws IOException { BufferedReader br=new BufferedReader(new FileReader("1.txt")); BufferedWriter bw=new BufferedWriter(new FileWriter("2.txt")); StreamTokenizer st=new StreamTokenizer(br); st.whitespaceChars(0, 32); st.eolIsSignificant(true); int tokenType; while(br.ready()) { tokenType=st.nextToken(); switch(tokenType) { case st.TT_NUMBER://这里报错,说例表达式必须是常量表达式,但不知道应该怎么改 bw.write(String.valueOf((long)st.nval)); bw.newLine(); break; case st.TT_WORD://同上 bw.write(st.sval); bw.newLine(); break; } } bw.close(); } }