semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public void elimina(Cliente cli) throws errorSQL, errorConexionBD {
        System.out.println("GestorCliente.elimina()");
        int id = cli.getId();
        String sql;
        Statement stmt = null;
        try {
            gd.begin();
            sql = "DELETE FROM cliente WHERE cod_cliente =" + id;
            System.out.println("Ejecutando: " + sql);
            stmt = gd.getConexion().createStatement();
            stmt.executeUpdate(sql);
            sql = "DELETE FROM usuario WHERE cod_usuario =" + id;
            System.out.println("Ejecutando: " + sql);
            stmt = gd.getConexion().createStatement();
            stmt.executeUpdate(sql);
            System.out.println("executeUpdate");
            sql = "DELETE FROM persona WHERE id =" + id;
            System.out.println("Ejecutando: " + sql);
            stmt = gd.getConexion().createStatement();
            stmt.executeUpdate(sql);
            gd.commit();
            System.out.println("commit");
            stmt.close();
        } catch (SQLException e) {
            gd.rollback();
            throw new errorSQL(e.toString());
        } catch (errorConexionBD e) {
            System.err.println("Error en GestorCliente.elimina(): " + e);
        } catch (errorSQL e) {
            System.err.println("Error en GestorCliente.elimina(): " + e);
        }
    }
private static void discoverRegisteryEntries(DataSourceRegistry registry) {
        try {
            Enumeration<URL> urls = DataSetURL.class.getClassLoader().getResources("META-INF/org.virbo.datasource.DataSourceFactory.extensions");
            while (urls.hasMoreElements()) {
                URL url = urls.nextElement();
                BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
                String s = reader.readLine().trim();
                while (s != null) {
                    if (s.length() > 0) {
                        String[] ss = s.split("\\s");
                        for (int i = 1; i < ss.length; i++) {
                            registry.registerExtension(ss[0], ss[i], null);
                        }
                    }
                    s = reader.readLine();
                }
                reader.close();
            }
            urls = DataSetURL.class.getClassLoader().getResources("META-INF/org.virbo.datasource.DataSourceFactory.mimeTypes");
            while (urls.hasMoreElements()) {
                URL url = urls.nextElement();
                BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
                String s = reader.readLine().trim();
                while (s != null) {
                    if (s.length() > 0) {
                        String[] ss = s.split("\\s");
                        for (int i = 1; i < ss.length; i++) {
                            registry.registerMimeType(ss[0], ss[i]);
                        }
                    }
                    s = reader.readLine();
                }
                reader.close();
            }
            urls = DataSetURL.class.getClassLoader().getResources("META-INF/org.virbo.datasource.DataSourceFormat.extensions");
            while (urls.hasMoreElements()) {
                URL url = urls.nextElement();
                BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
                String s = reader.readLine().trim();
                while (s != null) {
                    if (s.length() > 0) {
                        String[] ss = s.split("\\s");
                        for (int i = 1; i < ss.length; i++) {
                            registry.registerFormatter(ss[0], ss[i]);
                        }
                    }
                    s = reader.readLine();
                }
                reader.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
private static QDataSet test3_binary() throws IOException, StreamException {
        URL url = TestQDataSetStreamHandler.class.getResource("test3.binary.qds");
        QDataSetStreamHandler handler = new QDataSetStreamHandler();
        StreamTool.readStream(Channels.newChannel(url.openStream()), handler);
        QDataSet qds = handler.getDataSet();
        return qds;
    }
protected InputSource loadExternalSdl(String aActualLocation) throws RuntimeException {
        logger.debug("loadExternalSdl(String) " + aActualLocation);
        try {
            URL url = new URL(aActualLocation);
            return new InputSource(url.openStream());
        } catch (MalformedURLException e) {
            logger.error(e);
            throw new RuntimeException(aActualLocation + AeMessages.getString("AeWsdlLocator.ERROR_1"), e);
        } catch (IOException e) {
            logger.error(e);
            throw new RuntimeException(AeMessages.getString("AeWsdlLocator.ERROR_2") + aActualLocation, e);
        }
    }
@Override
    public void run() {
        try {
            File[] inputFiles = new File[this.previousFiles != null ? this.previousFiles.length + 1 : 1];
            File copiedInput = new File(this.randomFolder, this.inputFile.getName());
            IOUtils.copyFile(this.inputFile, copiedInput);
            inputFiles[inputFiles.length - 1] = copiedInput;
            if (previousFiles != null) {
                for (int i = 0; i < this.previousFiles.length; i++) {
                    File prev = this.previousFiles[i];
                    File copiedPrev = new File(this.randomFolder, prev.getName());
                    IOUtils.copyFile(prev, copiedPrev);
                    inputFiles[i] = copiedPrev;
                }
            }
            org.happycomp.radiog.Activator activator = org.happycomp.radiog.Activator.getDefault();
            if (this.exportedMP3File != null) {
                EncodingUtils.encodeToWavAndThenMP3(inputFiles, this.exportedWavFile, this.exportedMP3File, this.deleteOnExit, this.randomFolder, activator.getCommandsMap());
            } else {
                EncodingUtils.encodeToWav(inputFiles, this.exportedWavFile, randomFolder, activator.getCommandsMap());
            }
            if (encodeMonitor != null) {
                encodeMonitor.setEncodingFinished(true);
            }
        } catch (IOException e) {
            LOGGER.log(Level.SEVERE, e.getMessage(), e);
        }
    }
@Override
    public String encodePassword(final String password, final Object salt) {
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.reset();
            digest.update(salt.toString().getBytes());
            byte[] passwordHash = digest.digest(password.getBytes());
            Base64 encoder = new Base64();
            byte[] encoded = encoder.encode(passwordHash);
            return new String(encoded);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
public boolean onStart() {
        log("Starting up, this may take a minute...");
        gui = new ApeAtollGUI();
        gui.setVisible(true);
        while (waitGUI) {
            sleep(100);
        }
        URLConnection url = null;
        BufferedReader in = null;
        BufferedWriter out = null;
        if (checkUpdates) {
            try {
                url = new URL("http://www.voltrex.be/rsbot/VoltrexApeAtollVERSION.txt").openConnection();
                in = new BufferedReader(new InputStreamReader(url.getInputStream()));
                if (Double.parseDouble(in.readLine()) > properties.version()) {
                    if (JOptionPane.showConfirmDialog(null, "Update found. Do you want to update?") == 0) {
                        JOptionPane.showMessageDialog(null, "Please choose 'VoltrexApeAtoll.java' in your scripts/sources folder.");
                        JFileChooser fc = new JFileChooser();
                        if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
                            url = new URL("http://www.voltrex.be/rsbot/VoltrexApeAtoll.java").openConnection();
                            in = new BufferedReader(new InputStreamReader(url.getInputStream()));
                            out = new BufferedWriter(new FileWriter(fc.getSelectedFile().getPath()));
                            String inp;
                            while ((inp = in.readLine()) != null) {
                                out.write(inp);
                                out.newLine();
                                out.flush();
                            }
                            log("Script successfully downloaded. Please recompile.");
                            return false;
                        } else log("Update canceled");
                    } else log("Update canceled");
                } else log("You have the latest version.");
                if (in != null) in.close();
                if (out != null) out.close();
            } catch (IOException e) {
                log("Problem getting version. Please report this bug!");
            }
        }
        try {
            BKG = ImageIO.read(new URL("http://i54.tinypic.com/2egcfaw.jpg"));
        } catch (final java.io.IOException e) {
            e.printStackTrace();
        }
        try {
            final URL cursorURL = new URL("http://imgur.com/i7nMG.png");
            final URL cursor80URL = new URL("http://imgur.com/8k9op.png");
            normal = ImageIO.read(cursorURL);
            clicked = ImageIO.read(cursor80URL);
        } catch (MalformedURLException e) {
            log.info("Unable to buffer cursor.");
        } catch (IOException e) {
            log.info("Unable to open cursor image.");
        }
        scriptStartTime = System.currentTimeMillis();
        mouse.setSpeed(MouseSpeed);
        camera.setPitch(true);
        log("You are using Voltrex Ape Atoll agility course.");
        return true;
    }
private void update() throws IOException {
            FileOutputStream out = new FileOutputStream(combined);
            try {
                File[] _files = listJavascript();
                List<File> files = new ArrayList<File>(Arrays.asList(_files));
                files.add(0, new File(jsdir.getAbsolutePath() + "/leemba.js"));
                files.add(0, new File(jsdir.getAbsolutePath() + "/jquery.min.js"));
                for (File js : files) {
                    FileInputStream fin = null;
                    try {
                        int count = 0;
                        byte buf[] = new byte[16384];
                        fin = new FileInputStream(js);
                        while ((count = fin.read(buf)) > 0) out.write(buf, 0, count);
                    } catch (Throwable t) {
                        log.error("Failed to read file: " + js.getAbsolutePath(), t);
                    } finally {
                        if (fin != null) fin.close();
                    }
                }
            } finally {
                out.close();
            }
        }
protected static boolean checkVersion(String address) {
        Scanner scanner = null;
        try {
            URL url = new URL(address);
            InputStream iS = url.openStream();
            scanner = new Scanner(iS);
            if (scanner == null && DEBUG) System.out.println("SCANNER NULL");
            String firstLine = scanner.nextLine();
            double latestVersion = Double.valueOf(firstLine.trim());
            double thisVersion = JCards.VERSION;
            if (thisVersion >= latestVersion) {
                JCards.latestVersion = true;
            } else {
                displaySimpleAlert(null, JCards.VERSION_PREFIX + latestVersion + " is available online!\n" + "Look under the file menu for a link to the download site.");
            }
        } catch (Exception e) {
            if (VERBOSE || DEBUG) {
                System.out.println("Can't decide latest version");
                e.printStackTrace();
            }
            return false;
        }
        return true;
    }
public Main(String[] args) {
        boolean encrypt = false;
        if (args[0].compareTo("-e") == 0) {
            encrypt = true;
        } else if (args[0].compareTo("-d") == 0) {
            encrypt = false;
        } else {
            System.out.println("first argument is invalid");
            System.exit(-2);
        }
        char[] password = new char[args[2].length()];
        for (int i = 0; i < args[2].length(); i++) {
            password[i] = (char) args[2].getBytes()[i];
        }
        try {
            InitializeCipher(encrypt, password);
        } catch (Exception e) {
            System.out.println("error initializing cipher");
            System.exit(-3);
        }
        try {
            InputStream is = new FileInputStream(args[1]);
            OutputStream os;
            int read, max = 10;
            byte[] buffer = new byte[max];
            if (encrypt) {
                os = new FileOutputStream(args[1] + ".enc");
                os = new CipherOutputStream(os, cipher);
            } else {
                os = new FileOutputStream(args[1] + ".dec");
                is = new CipherInputStream(is, cipher);
            }
            read = is.read(buffer);
            while (read != -1) {
                os.write(buffer, 0, read);
                read = is.read(buffer);
            }
            while (read == max) ;
            os.close();
            is.close();
            System.out.println(new String(buffer));
        } catch (Exception e) {
            System.out.println("error encrypting/decrypting message:");
            e.printStackTrace();
            System.exit(-4);
        }
        System.out.println("done");
    }
public String encryptToMD5(String info) {
        byte[] digesta = null;
        try {
            MessageDigest alga = MessageDigest.getInstance("MD5");
            alga.update(info.getBytes());
            digesta = alga.digest();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        String rs = byte2hex(digesta);
        return rs;
    }
public String encryptToSHA(String info) {
        byte[] digesta = null;
        try {
            MessageDigest alga = MessageDigest.getInstance("SHA-1");
            alga.update(info.getBytes());
            digesta = alga.digest();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        String rs = byte2hex(digesta);
        return rs;
    }
private static void loadPluginsFromClassLoader(ClassLoader classLoader) throws IOException {
        Enumeration res = classLoader.getResources("META-INF/services/" + GDSFactoryPlugin.class.getName());
        while (res.hasMoreElements()) {
            URL url = (URL) res.nextElement();
            InputStreamReader rin = new InputStreamReader(url.openStream());
            BufferedReader bin = new BufferedReader(rin);
            while (bin.ready()) {
                String className = bin.readLine();
                try {
                    Class clazz = Class.forName(className);
                    GDSFactoryPlugin plugin = (GDSFactoryPlugin) clazz.newInstance();
                    registerPlugin(plugin);
                } catch (ClassNotFoundException ex) {
                    if (log != null) log.error("Can't register plugin" + className, ex);
                } catch (IllegalAccessException ex) {
                    if (log != null) log.error("Can't register plugin" + className, ex);
                } catch (InstantiationException ex) {
                    if (log != null) log.error("Can't register plugin" + className, ex);
                }
            }
        }
    }
private void extractZipFile(String filename, JTextPane progressText) throws IOException {
        String destinationname = "";
        byte[] buf = new byte[1024];
        ZipInputStream zipinputstream = null;
        ZipEntry zipentry;
        zipinputstream = new ZipInputStream(new FileInputStream(filename));
        while ((zipentry = zipinputstream.getNextEntry()) != null) {
            String entryName = zipentry.getName();
            if (progressText != null) {
                progressText.setText("extracting " + entryName);
            }
            int n;
            FileOutputStream fileoutputstream;
            if (zipentry.isDirectory()) {
                (new File(destinationname + entryName)).mkdir();
                continue;
            }
            fileoutputstream = new FileOutputStream(destinationname + entryName);
            while ((n = zipinputstream.read(buf, 0, 1024)) > -1) fileoutputstream.write(buf, 0, n);
            fileoutputstream.close();
            zipinputstream.closeEntry();
        }
        if (progressText != null) {
            progressText.setText("Files extracted");
        }
        zipinputstream.close();
    }
protected String readScript(ClassLoader cl, String scriptName) throws AxisFault {
        URL url = cl.getResource(scriptName);
        if (url == null) {
            throw new AxisFault("Script not found: " + scriptName);
        }
        InputStream is;
        try {
            is = url.openStream();
        } catch (IOException e) {
            throw new AxisFault("IOException opening script: " + scriptName, e);
        }
        try {
            Reader reader = new InputStreamReader(is, "UTF-8");
            char[] buffer = new char[1024];
            StringBuffer source = new StringBuffer();
            int count;
            while ((count = reader.read(buffer)) > 0) {
                source.append(buffer, 0, count);
            }
            return source.toString();
        } catch (IOException e) {
            throw new AxisFault("IOException reading script: " + scriptName, e);
        } finally {
            try {
                is.close();
            } catch (IOException e) {
                throw new AxisFault("IOException closing script: " + scriptName, e);
            }
        }
    }
protected TaobaoResponse _fetch(HttpPost post, Map<String, CharSequence> payload, File file) throws IOException {
        Set<Entry<String, CharSequence>> entries = payload.entrySet();
        List<NameValuePair> nvps = new ArrayList<NameValuePair>();
        for (Entry<String, CharSequence> entry : entries) {
            NameValuePair nvp = new BasicNameValuePair(entry.getKey(), (String) entry.getValue());
            nvps.add(nvp);
        }
        if (file != null) {
        } else {
            post.setEntity(new UrlEncodedFormEntity(nvps, HTTP.UTF_8));
        }
        if (this.keepAlive) {
            post.setHeader("Connection", "Keep-Alive");
        }
        Header responseHeader = null;
        HttpResponse response = httpClient.execute(post);
        responseHeader = post.getLastHeader("sip_status");
        String body = EntityUtils.toString(response.getEntity());
        TaobaoResponse urlRsp = new TaobaoResponse();
        if (responseHeader != null) {
            String status = responseHeader.getValue();
            if (!SIP_STATUS_OK.equals(status)) {
                urlRsp.setErrorCode(status);
                urlRsp.setMsg(post.getLastHeader("sip_error_message").getValue());
                if (status.equals("1004")) {
                    urlRsp.setRedirectUrl(post.getLastHeader("sip_isp_loginurl").getValue());
                }
            }
        }
        urlRsp.setBody(body);
        return urlRsp;
    }
public String contentType() {
        if (_contentType != null) {
            return (String) _contentType;
        }
        String uti = null;
        URL url = url();
        System.out.println("OKIOSIDManagedObject.contentType(): url = " + url + "\n");
        if (url != null) {
            String contentType = null;
            try {
                contentType = url.openConnection().getContentType();
            } catch (java.io.IOException e) {
                System.out.println("OKIOSIDManagedObject.contentType(): couldn't open URL connection!\n");
                return UTType.Item;
            }
            if (contentType != null) {
                System.out.println("OKIOSIDManagedObject.contentType(): contentType = " + contentType + "\n");
                uti = UTType.preferredIdentifierForTag(UTType.MIMETypeTagClass, contentType, null);
            }
            if (uti == null) {
                uti = UTType.Item;
            }
        } else {
            uti = UTType.Item;
        }
        _contentType = uti;
        System.out.println("OKIOSIDManagedObject.contentType(): uti = " + uti + "\n");
        return uti;
    }
public static void main(String[] args) throws FileNotFoundException {
        if (args.length < 2) throw new IllegalArgumentException();
        String fnOut = args[args.length - 1];
        PrintWriter writer = new PrintWriter(fnOut);
        for (int i = 0; i < args.length - 1; i++) {
            File fInput = new File(args[i]);
            Scanner in = new Scanner(fInput);
            while (in.hasNext()) {
                writer.println(in.nextLine());
            }
        }
        writer.close();
    }
public synchronized String encrypt(String plaintext) {
        if (plaintext == null) plaintext = "";
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("SHA");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return null;
        }
        try {
            md.update(plaintext.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return null;
        }
        byte raw[] = md.digest();
        String hash = "";
        try {
            hash = Base64Encoder.encode(raw);
        } catch (IOException e1) {
            System.err.println("Error encoding password using Jboss Base64Encoder");
            e1.printStackTrace();
        }
        return hash;
    }
public static void copy(File from_file, File to_file) throws IOException {
        if (!from_file.exists()) abort("FileCopy: no such source file: " + from_file.getName());
        if (!from_file.isFile()) abort("FileCopy: can't copy directory: " + from_file.getName());
        if (!from_file.canRead()) abort("FileCopy: source file is unreadable: " + from_file.getName());
        if (to_file.isDirectory()) to_file = new File(to_file, from_file.getName());
        if (to_file.exists()) {
            if (!to_file.canWrite()) abort("FileCopy: destination file is unwriteable: " + to_file.getName());
        } else {
            String parent = to_file.getParent();
            if (parent == null) parent = System.getProperty("user.dir");
            File dir = new File(parent);
            if (!dir.exists()) abort("FileCopy: destination directory doesn't exist: " + parent);
            if (dir.isFile()) abort("FileCopy: destination is not a directory: " + parent);
            if (!dir.canWrite()) abort("FileCopy: destination directory is unwriteable: " + parent);
        }
        FileInputStream from = null;
        FileOutputStream to = null;
        try {
            from = new FileInputStream(from_file);
            to = new FileOutputStream(to_file);
            byte[] buffer = new byte[4096];
            int bytes_read;
            while ((bytes_read = from.read(buffer)) != -1) {
                to.write(buffer, 0, bytes_read);
            }
        } finally {
            if (from != null) {
                try {
                    from.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (to != null) {
                try {
                    to.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }