public static void main(String[] args) {
        BufferedReader reader;
        File file = new File("D:/www/tmp/10.183.131.236-20150309-php_2701sell.log");
        String root = "d:/www/tmp/";
        Map<String, FileWriter> fileWriteMap = new HashMap();
        String[] typeArray = new String[]{"tid"};//$act, $value, $value2 , $tid (map_id), $item
        try {
            reader = new BufferedReader(new FileReader(file));
            String partter;
            FileWriter currentWriter;
            while ((partter = reader.readLine()) != null) {
                //act,value,value2,tid,item
                Map<String, String> info = formatMsg(partter);
//                System.out.println(info.get("msg"));
                for (String type : typeArray) {
                    String fileName = generateFileName(info, root, type);

                    if (fileWriteMap.containsKey(fileName)) {
                        currentWriter = fileWriteMap.get(fileName);
                    } else {
                        File tmpFile = new File(fileName);
                        if (!tmpFile.exists()) {
                            tmpFile.getParentFile().mkdirs();//先创建父文件夹 然后在创建文件 要不然会抛异常
                            tmpFile.createNewFile();
                        }
                        currentWriter = new FileWriter(tmpFile, true);
                        fileWriteMap.put(fileName, currentWriter);
                    }
                    currentWriter.write(info.get("msg") + "\r\n");
                }
            }
        } catch (IOException ex) {
            Logger.getLogger(FileLogFormat.class.getName()).log(Level.SEVERE, null, ex);
        } finally {
            fileWriteMap.entrySet().stream().forEach((entry) -> {
                try {
                    entry.getValue().close();
                } catch (IOException ex) {
                    Logger.getLogger(FileLogFormat.class.getName()).log(Level.SEVERE, null, ex);
                }
            });
        }
    }