MapReduce计算每年最大值测试样例生成程序
Demo.java
package com.java; import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Random; /** * 随机生成从2000到2018每天一个随机四位数,用于MapReduce计算每年最大值测试 * * @author Logan * @createDate 2019-03-18 * @version 1.0.0 * */ public class Demo { /** * 生成文件存放在D盘1.txt */ private static final String PATH = "D:\\1.txt"; private static final SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd"); public static void main(String[] args) { File file = new File(PATH); try ( FileWriter writer = new FileWriter(file); BufferedWriter bufWriter = new BufferedWriter(writer); ) { if (!file.exists()) { file.createNewFile(); } Calendar start = Calendar.getInstance(); Calendar end = Calendar.getInstance(); start.set(2000, 0, 1); end.set(2018, 0, 1); StringBuffer line = null; while (start.before(end)) { line = new StringBuffer(); line.append(format.format(start.getTime())); line.append(getRandom()).append("\n"); bufWriter.write(line.toString()); start.add(Calendar.DATE, 1); } } catch (Exception e) { e.printStackTrace(); } } /** * 随机生成一个四位整数 * * @return */ private static int getRandom() { Random r = new Random(); return r.nextInt(9000) + 1000; } }
计算程序参见:
https://www.cnblogs.com/jonban/p/10555826.html
.