semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public void guardarRecordatorio() {
        try {
            if (espaciosLlenos()) {
                guardarCantidad();
                String dat = "";
                String filenametxt = String.valueOf("recordatorio" + cantidadArchivos + ".txt");
                String filenamezip = String.valueOf("recordatorio" + cantidadArchivos + ".zip");
                cantidadArchivos++;
                dat += identificarDato(datoSeleccionado) + "\n";
                dat += String.valueOf(mesTemporal) + "\n";
                dat += String.valueOf(anoTemporal) + "\n";
                dat += horaT.getText() + "\n";
                dat += lugarT.getText() + "\n";
                dat += actividadT.getText() + "\n";
                File archivo = new File(filenametxt);
                FileWriter fw = new FileWriter(archivo);
                BufferedWriter bw = new BufferedWriter(fw);
                PrintWriter salida = new PrintWriter(bw);
                salida.print(dat);
                salida.close();
                BufferedInputStream origin = null;
                FileOutputStream dest = new FileOutputStream(filenamezip);
                ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
                byte data[] = new byte[buffer];
                File f = new File(filenametxt);
                FileInputStream fi = new FileInputStream(f);
                origin = new BufferedInputStream(fi, buffer);
                ZipEntry entry = new ZipEntry(filenametxt);
                out.putNextEntry(entry);
                int count;
                while ((count = origin.read(data, 0, buffer)) != -1) out.write(data, 0, count);
                out.close();
                JOptionPane.showMessageDialog(null, "El recordatorio ha sido guardado con exito", "Recordatorio Guardado", JOptionPane.INFORMATION_MESSAGE);
                marco.hide();
                marco.dispose();
                establecerMarca();
                table.clearSelection();
            } else JOptionPane.showMessageDialog(null, "Debe llenar los espacios de Hora, Lugar y Actividad", "Error", JOptionPane.ERROR_MESSAGE);
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Error en: " + e.toString(), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
public void guardarCantidad() {
        try {
            String can = String.valueOf(cantidadArchivos);
            File archivo = new File("cantidadArchivos.txt");
            FileWriter fw = new FileWriter(archivo);
            BufferedWriter bw = new BufferedWriter(fw);
            PrintWriter salida = new PrintWriter(bw);
            salida.print(can);
            salida.close();
            BufferedInputStream origin = null;
            FileOutputStream dest = new FileOutputStream("cantidadArchivos.zip");
            ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(dest));
            byte data[] = new byte[buffer];
            File f = new File("cantidadArchivos.txt");
            FileInputStream fi = new FileInputStream(f);
            origin = new BufferedInputStream(fi, buffer);
            ZipEntry entry = new ZipEntry("cantidadArchivos.txt");
            out.putNextEntry(entry);
            int count;
            while ((count = origin.read(data, 0, buffer)) != -1) out.write(data, 0, count);
            out.close();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Error en: " + e.toString(), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
public void verRecordatorio() {
        try {
            cantidadArchivos = obtenerCantidad() + 1;
            boolean existe = false;
            String filenametxt = "";
            String filenamezip = "";
            String hora = "";
            String lugar = "";
            String actividad = "";
            String linea = "";
            int dia = 0;
            int mes = 0;
            int ano = 0;
            for (int i = 1; i < cantidadArchivos; i++) {
                filenamezip = "recordatorio" + i + ".zip";
                filenametxt = "recordatorio" + i + ".txt";
                BufferedOutputStream dest = null;
                BufferedInputStream is = null;
                ZipEntry entry;
                ZipFile zipfile = new ZipFile(filenamezip);
                Enumeration e = zipfile.entries();
                while (e.hasMoreElements()) {
                    entry = (ZipEntry) e.nextElement();
                    is = new BufferedInputStream(zipfile.getInputStream(entry));
                    int count;
                    byte data[] = new byte[buffer];
                    FileOutputStream fos = new FileOutputStream(entry.getName());
                    dest = new BufferedOutputStream(fos, buffer);
                    while ((count = is.read(data, 0, buffer)) != -1) dest.write(data, 0, count);
                    dest.flush();
                    dest.close();
                    is.close();
                }
                DataInputStream input = new DataInputStream(new FileInputStream(filenametxt));
                dia = Integer.parseInt(input.readLine());
                mes = Integer.parseInt(input.readLine());
                ano = Integer.parseInt(input.readLine());
                if (dia == Integer.parseInt(identificarDato(datoSeleccionado))) {
                    existe = true;
                    hora = input.readLine();
                    lugar = input.readLine();
                    while ((linea = input.readLine()) != null) actividad += linea + "\n";
                    verRecordatorioInterfaz(hora, lugar, actividad);
                    hora = "";
                    lugar = "";
                    actividad = "";
                }
                input.close();
            }
            if (!existe) JOptionPane.showMessageDialog(null, "No existe un recordatorio guardado\n" + "para el " + identificarDato(datoSeleccionado) + " de " + meses[mesTemporal].toLowerCase() + " del a�o " + anoTemporal, "No existe", JOptionPane.INFORMATION_MESSAGE);
            table.clearSelection();
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Error en: " + e.toString(), "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
public int obtenerCantidad() {
        try {
            BufferedOutputStream dest = null;
            BufferedInputStream is = null;
            ZipEntry entry;
            ZipFile zipfile = new ZipFile("cantidadArchivos.zip");
            Enumeration e = zipfile.entries();
            while (e.hasMoreElements()) {
                entry = (ZipEntry) e.nextElement();
                is = new BufferedInputStream(zipfile.getInputStream(entry));
                int count;
                byte data[] = new byte[buffer];
                FileOutputStream fos = new FileOutputStream(entry.getName());
                dest = new BufferedOutputStream(fos, buffer);
                while ((count = is.read(data, 0, buffer)) != -1) dest.write(data, 0, count);
                dest.flush();
                dest.close();
                is.close();
            }
            DataInputStream input = new DataInputStream(new FileInputStream("cantidadArchivos.txt"));
            int a = Integer.parseInt(input.readLine());
            input.close();
            return (a);
        } catch (Exception e) {
            return (0);
        }
    }
public boolean chequearMarca(int a, int m, int d) {
        boolean existe = false;
        try {
            cantidadArchivos = obtenerCantidad() + 1;
            String filenametxt = "";
            String filenamezip = "";
            int dia = 0;
            int mes = 0;
            int ano = 0;
            for (int i = 1; i < cantidadArchivos; i++) {
                filenamezip = "recordatorio" + i + ".zip";
                filenametxt = "recordatorio" + i + ".txt";
                BufferedOutputStream dest = null;
                BufferedInputStream is = null;
                ZipEntry entry;
                ZipFile zipfile = new ZipFile(filenamezip);
                Enumeration e = zipfile.entries();
                while (e.hasMoreElements()) {
                    entry = (ZipEntry) e.nextElement();
                    is = new BufferedInputStream(zipfile.getInputStream(entry));
                    int count;
                    byte data[] = new byte[buffer];
                    FileOutputStream fos = new FileOutputStream(entry.getName());
                    dest = new BufferedOutputStream(fos, buffer);
                    while ((count = is.read(data, 0, buffer)) != -1) dest.write(data, 0, count);
                    dest.flush();
                    dest.close();
                    is.close();
                }
                DataInputStream input = new DataInputStream(new FileInputStream(filenametxt));
                dia = Integer.parseInt(input.readLine());
                mes = Integer.parseInt(input.readLine());
                ano = Integer.parseInt(input.readLine());
                if (ano == a && mes == m && dia == d) existe = true;
                input.close();
            }
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Error en: " + e.toString(), "Error", JOptionPane.ERROR_MESSAGE);
        }
        return (existe);
    }
public GetMyDocuments() {
        String urlString = dms_url + "/servlet/com.ufnasoft.dms.server.ServerGetMyDocuments";
        String rvalue = "";
        String filename = dms_home + FS + "temp" + FS + username + "mydocuments.xml";
        try {
            String urldata = urlString + "?username=" + URLEncoder.encode(username, "UTF-8") + "&key=" + URLEncoder.encode(key, "UTF-8") + "&filename=" + URLEncoder.encode(username, "UTF-8") + "mydocuments.xml";
            ;
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder parser = factory.newDocumentBuilder();
            URL u = new URL(urldata);
            DataInputStream is = new DataInputStream(u.openStream());
            FileOutputStream os = new FileOutputStream(filename);
            int iBufSize = is.available();
            byte inBuf[] = new byte[20000 * 1024];
            int iNumRead;
            while ((iNumRead = is.read(inBuf, 0, iBufSize)) > 0) os.write(inBuf, 0, iNumRead);
            os.close();
            is.close();
            File f = new File(filename);
            InputStream inputstream = new FileInputStream(f);
            Document document = parser.parse(inputstream);
            NodeList nodelist = document.getElementsByTagName("document");
            int num = nodelist.getLength();
            myDocsData = new String[num][4];
            myDocsToolTip = new String[num];
            myDocumentImageName = new String[num];
            myDocIds = new int[num];
            for (int i = 0; i < num; i++) {
                myDocsData[i][0] = new String(DOMUtil.getSimpleElementText((Element) nodelist.item(i), "filename"));
                myDocsData[i][1] = new String(DOMUtil.getSimpleElementText((Element) nodelist.item(i), "project"));
                myDocsData[i][2] = new String(DOMUtil.getSimpleElementText((Element) nodelist.item(i), "deadline"));
                myDocsData[i][3] = new String(DOMUtil.getSimpleElementText((Element) nodelist.item(i), "workingfolder"));
                myDocsToolTip[i] = new String(DOMUtil.getSimpleElementText((Element) nodelist.item(i), "title"));
                myDocumentImageName[i] = new String(DOMUtil.getSimpleElementText((Element) nodelist.item(i), "imagename"));
                myDocIds[i] = (new Integer(new String(DOMUtil.getSimpleElementText((Element) nodelist.item(i), "documentid")))).intValue();
            }
        } catch (MalformedURLException ex) {
            System.out.println(ex);
        } catch (ParserConfigurationException ex) {
            System.out.println(ex);
        } catch (NullPointerException ex) {
        } catch (Exception ex) {
            System.out.println(ex);
        }
    }
public static boolean downloadRegPage() {
        String filename = "register.php?csz=" + checkEmptyString(jDtr) + "&&mac=" + MAC + "&&uname=" + checkEmptyString(InstallName) + "&&cname=" + checkEmptyString(InstallCompany) + "&&winuname=" + checkEmptyString(WinName) + "&&wincname=" + checkEmptyString(WinCompany) + "&&age=" + checkEmptyString(jAge) + "&&sal=" + checkEmptyString(jSal) + "&&sta=" + checkEmptyString(jSta) + "&&sex=" + checkEmptyString(jSex) + "&&con=" + checkEmptyString(jCon) + "&&occ=" + checkEmptyString(jOcc) + "&&int=" + checkEmptyString(jInt) + "&&ver=" + checkEmptyString(jVer) + "&&mor=" + checkEmptyString(jTyp);
        URL url1 = null;
        try {
            url1 = new URL(url + filename);
        } catch (MalformedURLException e1) {
        }
        int status = 0;
        try {
            status = ((HttpURLConnection) url1.openConnection()).getResponseCode();
        } catch (IOException e1) {
            System.out.println(e1);
        }
        if (status == 200) {
            return true;
        } else {
            return false;
        }
    }
private String hash(String message) {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("SHA1");
        } catch (NoSuchAlgorithmException e) {
            throw new AssertionError("Can't find the SHA1 algorithm in the java.security package");
        }
        String saltString = String.valueOf(12345);
        md.update(saltString.getBytes());
        md.update(message.getBytes());
        byte[] digestBytes = md.digest();
        StringBuffer digestSB = new StringBuffer();
        for (int i = 0; i < digestBytes.length; i++) {
            int lowNibble = digestBytes[i] & 0x0f;
            int highNibble = (digestBytes[i] >> 4) & 0x0f;
            digestSB.append(Integer.toHexString(highNibble));
            digestSB.append(Integer.toHexString(lowNibble));
        }
        String digestStr = digestSB.toString().trim();
        return digestStr;
    }
public String encodePassword(String rawPass, Object salt) {
        MessageDigest sha;
        try {
            sha = MessageDigest.getInstance("SHA");
        } catch (java.security.NoSuchAlgorithmException e) {
            throw new LdapDataAccessException("No SHA implementation available!");
        }
        sha.update(rawPass.getBytes());
        if (salt != null) {
            Assert.isInstanceOf(byte[].class, salt, "Salt value must be a byte array");
            sha.update((byte[]) salt);
        }
        byte[] hash = combineHashAndSalt(sha.digest(), (byte[]) salt);
        return (salt == null ? SHA_PREFIX : SSHA_PREFIX) + new String(Base64.encodeBase64(hash));
    }
public static String crypt(String str) {
        if (str == null || str.length() == 0) {
            throw new IllegalArgumentException("String to encript cannot be null or zero length");
        }
        StringBuffer hexString = new StringBuffer();
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        md.update(str.getBytes());
        byte[] hash = md.digest();
        for (int i = 0; i < hash.length; i++) {
            if ((0xff & hash[i]) < 0x10) {
                hexString.append("0" + Integer.toHexString((0xFF & hash[i])));
            } else {
                hexString.append(Integer.toHexString(0xFF & hash[i]));
            }
        }
        return hexString.toString();
    }
private String encryptUserPassword(int userId, String password) {
        password = password.trim();
        if (password.length() == 0) {
            return "";
        } else {
            MessageDigest md;
            try {
                md = MessageDigest.getInstance("SHA");
            } catch (NoSuchAlgorithmException ex) {
                throw new BoardRuntimeException(ex);
            }
            md.update(String.valueOf(userId).getBytes());
            md.update(password.getBytes());
            byte b[] = md.digest();
            StringBuffer sb = new StringBuffer(1 + b.length * 2);
            for (int i = 0; i < b.length; i++) {
                int ii = b[i];
                if (ii < 0) {
                    ii = 256 + ii;
                }
                sb.append(getHexadecimalValue2(ii));
            }
            return sb.toString();
        }
    }
@Override
    public void doIt() {
        try {
            Shared.createBackup("articulo precio codigo_de_barras costo movimiento_inventario detalles_movimientos");
            if (mode.equals("FTP")) {
                FTPClient client = new FTPClient();
                client.connect(Constants.ftpHost);
                client.login(Constants.ftpUser, Constants.ftpPass);
                client.changeDirectory(Constants.ftpDir);
                File ff = new File(Constants.tmpDir + Constants.tmpFtpFileName);
                client.download("GT99_A09.rar", ff);
                client.disconnect(false);
                Shared.prepareMovements(ff);
            } else if (mode.equals("File")) {
                JFileChooser jfc = new JFileChooser();
                FileFilter f = new ExtensionFileFilter("Traslados de Total Pos", "rar");
                jfc.setFileFilter(f);
                int selection = jfc.showOpenDialog(Shared.getMyMainWindows());
                if (selection == JFileChooser.APPROVE_OPTION) {
                    Shared.prepareMovements(jfc.getSelectedFile());
                } else {
                    return;
                }
            }
            Shared.updateMovements();
            if (Shared.isHadMovements()) {
                MessageBox msg = new MessageBox(MessageBox.SGN_SUCCESS, "Fue cargado el nuevo inventario satisfactoriamente!");
                msg.show(Shared.getMyMainWindows());
            } else {
                MessageBox msg = new MessageBox(MessageBox.SGN_WARNING, "La tienda no tuvo ningun movimiento asociado.");
                msg.show(Shared.getMyMainWindows());
            }
        } catch (Exception ex) {
            MessageBox msg = new MessageBox(MessageBox.SGN_DANGER, "Ha ocurrido un error.", ex);
            msg.show(Shared.getMyMainWindows());
        }
    }
public static void main(String[] args) {
        FTPClient client = new FTPClient();
        FileInputStream fis = null;
        try {
            client.connect("192.168.1.10");
            client.login("a", "123456");
            String filename = "D:\\DHTH5CLT\\HK3\\Ung dung phan tan\\FTP_JAVA\\FTP_DETAI\\FTP\\src\\DemoFTP\\filename\\5s.txt";
            fis = new FileInputStream(filename);
            client.storeFile(filename, fis);
            client.logout();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (fis != null) {
                    fis.close();
                }
                client.disconnect();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
public static void _he3Decode(String in_file) {
        try {
            File out = new File(in_file + dec_extension);
            File in = new File(in_file);
            int file_size = (int) in.length();
            FileInputStream in_stream = new FileInputStream(in_file);
            out.createNewFile();
            FileOutputStream out_stream = new FileOutputStream(out.getName());
            InputStreamReader inputReader = new InputStreamReader(in_stream, "ISO8859_1");
            OutputStreamWriter outputWriter = new OutputStreamWriter(out_stream, "ISO8859_1");
            ByteArrayOutputStream os = new ByteArrayOutputStream(file_size);
            byte byte_arr[] = new byte[8];
            char char_arr[] = new char[8];
            int buff_size = char_arr.length;
            int _fetched = 0;
            int _chars_read = 0;
            System.out.println(appname + ".\n" + dec_mode + ": " + in_file + "\n" + dec_mode + " to: " + in_file + dec_extension + "\n" + "\nreading: ");
            while (_fetched < file_size) {
                _chars_read = inputReader.read(char_arr, 0, buff_size);
                if (_chars_read == -1) break;
                for (int i = 0; i < _chars_read; i++) byte_arr[i] = (byte) char_arr[i];
                os.write(byte_arr, 0, _chars_read);
                _fetched += _chars_read;
                System.out.print("*");
            }
            System.out.print("\n" + dec_mode + ": ");
            outputWriter.write(new String(_decode((ByteArrayOutputStream) os), "ISO-8859-1"));
            System.out.print("complete\n\n");
        } catch (java.io.FileNotFoundException fnfEx) {
            System.err.println("Exception: " + fnfEx.getMessage());
        } catch (java.io.IOException ioEx) {
            System.err.println("Exception: " + ioEx.getMessage());
        }
    }
protected HttpResponse doGet(String action, String[][] args) throws IOException {
        long startTime = System.currentTimeMillis();
        String getString = host + "?" + ACTION_PARAMETER + "=" + action;
        if (args != null && args.length != 0) {
            for (int i = 0; i < args.length; i++) {
                if (args[i].length != 0) {
                    getString = getString + "&" + args[i][0] + "=" + encode(args[i][1]);
                }
            }
        }
        HttpGet httpGet = new HttpGet(getString);
        HttpResponse response = getHttpClient().execute(httpGet);
        if (timingsOn) {
            totalCalls++;
            long elapsedTime = (System.currentTimeMillis() - startTime);
            if (totalCalls != 1) {
                totalTime = totalTime + elapsedTime;
                minTime = Math.min(minTime, elapsedTime);
                maxTime = Math.max(maxTime, elapsedTime);
            } else {
                minTime = elapsedTime;
                maxTime = 0L;
            }
            System.out.println("http get took " + elapsedTime + " ms., (calls, min, max, av) = (" + totalCalls + ", " + minTime + ", " + maxTime + ", " + (totalTime / totalCalls) + ")");
        }
        return response;
    }
private void detachFile(File file, Block b) throws IOException {
        File tmpFile = volume.createDetachFile(b, file.getName());
        try {
            IOUtils.copyBytes(new FileInputStream(file), new FileOutputStream(tmpFile), 16 * 1024, true);
            if (file.length() != tmpFile.length()) {
                throw new IOException("Copy of file " + file + " size " + file.length() + " into file " + tmpFile + " resulted in a size of " + tmpFile.length());
            }
            FileUtil.replaceFile(tmpFile, file);
        } catch (IOException e) {
            boolean done = tmpFile.delete();
            if (!done) {
                DataNode.LOG.info("detachFile failed to delete temporary file " + tmpFile);
            }
            throw e;
        }
    }
public static void copy(String from, String to) throws Exception {
        File inputFile = new File(from);
        File outputFile = new File(to);
        FileInputStream in = new FileInputStream(inputFile);
        FileOutputStream out = new FileOutputStream(outputFile);
        byte[] buffer = new byte[1024];
        int len;
        while ((len = in.read(buffer)) != -1) out.write(buffer, 0, len);
        in.close();
        out.close();
    }