问题描述
packagehelloworld;importjava.io.*;importjava.util.Scanner;publicclasshello{publicstaticvoidmain(Stringargs[]){StringfileName="C:\mark.txt";StringfileName2="C:\hello.txt";Stringline;//Strings="";intsum=0;try{FileWriterout=newFileWriter(fileName2);BufferedReaderin=newBufferedReader(newFileReader(fileName));line=in.readLine();while(line!=null){line=in.readLine();for(inti=0;i<line.indexOf("");i++){if(line.charAt(i)=='.'){System.out.println(line.charAt(i));sum+=1;}}System.out.println(sum);if(sum<2){System.out.println(line);out.write(line+"n");}sum=0;}in.close();out.close();}catch(IOExceptioniox){System.out.println("problem");}}}
解决方案
解决方案二:
搞定了。在判断改为:intc;while((c=in.read())!=-1)......................
时间: 2024-09-20 08:43:11