rt java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.util.Properties; /** * *
Application name:JAVA275
*
Application describing:读取配置文件,计算补贴金额 *
Copyright:Copyright &;copy; 2012 东软 软件开发事业部版权所有。
*
Company:Neusoft
*
Date:2012-2-24
* @author 杨小军 * @version $Revision: 1.2 $ */ public class CacAllowance { // private static float base; private static int base; private static int step; static { InputStream is = null; Properties prop = new Properties(); try { is = new FileInputStream("C:" + File.separator + "test" + File.separator + "config.properties"); prop.load(is);
} catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (is != null) { try { is.close(); } catch (IOException e) { e.printStackTrace(); } } //base = Float.parseFloat(prop.getProperty("base")); base = (int) Float.parseFloat(prop.getProperty("base")); step = Integer.parseInt(prop.getProperty("step")); } } /** * * 计算补贴金额 * * @param days * @return * @author:杨小军 */ public static int getAllowance(int days) { int grade = (int) days / 30; int allowance; if (grade == 0) { allowance = base * days;
} else if (grade == 1) { allowance = 30 * base + (days - 30) * (base + step); } else { allowance = 30 * (base * grade + grade * step * (grade - 1) / 2) + (days - 30 * grade) * (base + step + step * (grade - 1)); } return allowance; } } package com.neusoft.exam; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; /** * *
Application name:日期工厂类JAVA275
*
Application describing:字符串和日期间的转换 *
Copyright:Copyright &;copy; 2012 东软
软件开发事业部
版权所有。
*
Company:Neusoft
*
Date:2012-2-24
* @author 杨小军 * @version $Revision: 1.2 $ */ public class DateUtil { private static SimpleDat
eFormat sdf = new SimpleDateFormat("yyyy-M-d"); public static Date getDate(String dateStr) { Date dt = null; try { dt = sdf.parse(dateStr);
} catch (ParseException e) { throw new RuntimeException("日期格式转换错误", e); } return dt; } public static String getDateString(Date date) { return sdf.format(date); } public static int getdays(Date start, Date end) { long time = end.getTime() - start.getTime(); int days = (int) ((time) / (60 * 60 * 24 * 1000)) + 1; return days; } } package com.neusoft.exam; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; /** * *
Application name:文件操作类JAVA275
*
Application describing:读取文件和写文件 *
Copyright:Copyright &;copy; 2012 东软 软件开发事业部版权所有。
*
Company:Neusoft
*
Date:2012-2-24
* @author 杨小军 * @version $Revision: 1.2 $ */ public class FileOperate
{ public static List
readFile(String srcPath) { List lst = new ArrayList(); BufferedReader br = null; try { String line; br = new BufferedReader(new InputStreamReader(new FileInputStream(srcPath), "GBK")); while ((line = br.readLine()) != null) { lst.add(line); } } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } finally { if (br != null) { try { b