public class test2 { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { // TODO Auto-generated method stub File file = new File("C:\Users\Administrator\Desktop\a.txt"); FileInputStream inStream =new FileInputStream(file); BufferedReader in = new BufferedReader(new FileReader(file)); int call=0,i=0; String line=null; while((line=in.readLine())!=null ){ //System.out.println(line); int a=Integer.decode(line); System.out.println(a+"秒"); call+=a; i++; } while(inStream.read()!=-1){ //System.out.println(inStream.toString()); //call+=inStream.read(); } int hour=call/3600; int minute=(call%3600)/60; int second=(call%60); System.out.println(call+"秒"); System.out.println("共有"+i+"条记录,通话时间:"+hour+"小时"+minute+"分钟"+second+"秒"); System.out.print(hour*3600+minute*60+second+"秒"); } }
本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/702513