private void splitFile(final File file, long memoryLimit)
        throws IOException
    {
        LOG.info("Split start...");
        long start = System.currentTimeMillis();

        /*90% limit to avoid memory leak*/
        memoryLimit = (long)(memoryLimit * 0.95);

        String extension = file.getName().split("\\.")[1];
        File outDir = new File(file.getParentFile(), SPILT_FOLDER);
        if (!outDir.exists())
        {
            outDir.mkdir();
        }

        BufferedReader in = new BufferedReader(new FileReader(file));
        String line = null;
        int n = 0;
        String fileName = new StringBuilder(String.valueOf(n)).append(".").append(extension).toString();
        extension = null;

        File f = new File(outDir, fileName);
        BufferedWriter out = new BufferedWriter(new FileWriter(f));

        /*store header here*/
        header = in.readLine();
        long initilLen = memoryLimit / header.length();
        int i = 0;
        while ((line = in.readLine()) != null)
        {
            /*every length/100 get a judge to see the file size, it will enhancement the speed */
            if (i % (initilLen / 100) == 0 && f.length() >= memoryLimit)
            //            if (i >= lineLen)
            {
                i = 0;
                fileName = fileName.replaceFirst("^\\d+", String.valueOf(++n));
                out.flush();
                out.close();
                out = null;
                f = new File(outDir, fileName);
                out = new BufferedWriter(new FileWriter(f));
            }
            i++;
            out.write(line);
            out.newLine();
            out.flush();
        }

        outDir = null;
        fileName = null;
        if (out != null)
        {
            out.flush();
            out.close();
            out = null;
        }
        in.close();
        in = null;
        LOG.info("Split end, split time is {}ms.", System.currentTimeMillis() - start);
    }