public static void combineFile(String firstPart, String targetDirectory, CombineFileDialog cd) throws FileNotFoundException, IOException {
        File part = new File(firstPart);
        String nextFileName = firstPart;
        File[] files = part.getParentFile().listFiles();
        String dir = part.getParent();
        ArrayList<String> list = new ArrayList<String>();
        for (int i = 0; i < files.length; i++) {
            if (files[i].isFile()) {
                list.add(files[i].getAbsolutePath());
            }
        }
        boolean nextPart = true;
        String name2 = part.getName();
        String name = name2.substring(0, name2.lastIndexOf("."));
        File combinedFile = new File(targetDirectory + System.getProperty("file.separator") + name);
        combinedFile.createNewFile();
        OutputStream out = new FileOutputStream(combinedFile);
        InputStream inputStream;
        int len = 0;
        int nextPartNumber = 1;
        while (nextPart) {
            part = new File(nextFileName);
            cd.getjLabel2().setText(part.getName());
            inputStream = new FileInputStream(part);
            byte[] buf = new byte[5000000];
            while ((len = inputStream.read(buf)) != -1) {
                out.write(buf, 0, len);
            }
            out.flush();
            inputStream.close();

            String att = "";
            nextPartNumber = nextPartNumber + 1;
            if (nextPartNumber < 10) {
                att = "00" + nextPartNumber;
            } else if (nextPartNumber > 9 && nextPartNumber < 100) {
                att = "0" + nextPartNumber;
            } else if (nextPartNumber > 99) {
                att = nextPartNumber + "";
            }
            nextFileName = dir + System.getProperty("file.separator") + name + "." + att;
            if (list.contains(nextFileName)) {
                nextPart = true;
                list.remove(nextFileName);
            } else {
                nextPart = false;
            }
        }
        out.close();
    }