semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public static void adminUpdate(int i_id, double cost, String image, String thumbnail) {
        Connection con = null;
        try {
            tmpAdmin++;
            String name = "$tmp_admin" + tmpAdmin;
            con = getConnection();
            PreparedStatement related1 = con.prepareStatement("CREATE TEMPORARY TABLE " + name + " TYPE=HEAP SELECT o_id FROM orders ORDER BY o_date DESC LIMIT 10000");
            related1.executeUpdate();
            related1.close();
            PreparedStatement related2 = con.prepareStatement("SELECT ol2.ol_i_id, SUM(ol2.ol_qty) AS sum_ol FROM order_line ol, order_line ol2, " + name + " t " + "WHERE ol.ol_o_id = t.o_id AND ol.ol_i_id = ? AND ol2.ol_o_id = t.o_id AND ol2.ol_i_id <> ? " + "GROUP BY ol2.ol_i_id ORDER BY sum_ol DESC LIMIT 0,5");
            related2.setInt(1, i_id);
            related2.setInt(2, i_id);
            ResultSet rs = related2.executeQuery();
            int[] related_items = new int[5];
            int counter = 0;
            int last = 0;
            while (rs.next()) {
                last = rs.getInt(1);
                related_items[counter] = last;
                counter++;
            }
            for (int i = counter; i < 5; i++) {
                last++;
                related_items[i] = last;
            }
            rs.close();
            related2.close();
            PreparedStatement related3 = con.prepareStatement("DROP TABLE " + name);
            related3.executeUpdate();
            related3.close();
            PreparedStatement statement = con.prepareStatement("UPDATE item SET i_cost = ?, i_image = ?, i_thumbnail = ?, i_pub_date = CURRENT_DATE(), " + " i_related1 = ?, i_related2 = ?, i_related3 = ?, i_related4 = ?, i_related5 = ? WHERE i_id = ?");
            statement.setDouble(1, cost);
            statement.setString(2, image);
            statement.setString(3, thumbnail);
            statement.setInt(4, related_items[0]);
            statement.setInt(5, related_items[1]);
            statement.setInt(6, related_items[2]);
            statement.setInt(7, related_items[3]);
            statement.setInt(8, related_items[4]);
            statement.setInt(9, i_id);
            statement.executeUpdate();
            con.commit();
            statement.close();
            returnConnection(con);
        } catch (java.lang.Exception ex) {
            try {
                con.rollback();
                ex.printStackTrace();
            } catch (Exception se) {
                System.err.println("Transaction rollback failed.");
            }
        }
    }
public static int createEmptyCart() {
        int SHOPPING_ID = 0;
        Connection con = null;
        try {
            con = getConnection();
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
        }
        try {
            PreparedStatement insert_cart = null;
            SHOPPING_ID = Integer.parseInt(Sequence.getSequenceNumber("shopping_cart"));
            insert_cart = con.prepareStatement("INSERT INTO shopping_cart (sc_id, sc_time) VALUES ( ? , NOW() )");
            insert_cart.setInt(1, SHOPPING_ID);
            insert_cart.executeUpdate();
            con.commit();
            insert_cart.close();
            returnConnection(con);
        } catch (java.lang.Exception ex) {
            try {
                con.rollback();
                ex.printStackTrace();
            } catch (Exception se) {
                System.err.println("Transaction rollback failed.");
            }
        }
        return SHOPPING_ID;
    }
public static void refreshSession(int C_ID) {
        Connection con = null;
        try {
            con = getConnection();
            PreparedStatement updateLogin = con.prepareStatement("UPDATE customer SET c_login = NOW(), c_expiration = DATE_ADD(NOW(), INTERVAL 2 HOUR) WHERE c_id = ?");
            updateLogin.setInt(1, C_ID);
            updateLogin.executeUpdate();
            con.commit();
            updateLogin.close();
            returnConnection(con);
        } catch (java.lang.Exception ex) {
            try {
                con.rollback();
                ex.printStackTrace();
            } catch (Exception se) {
                System.err.println("Transaction rollback failed.");
            }
        }
    }
private static String getVisitorId(String guid, String account, String userAgent, Cookie cookie) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        if (cookie != null && cookie.getValue() != null) {
            return cookie.getValue();
        }
        String message;
        if (!isEmpty(guid)) {
            message = guid + account;
        } else {
            message = userAgent + getRandomNumber() + UUID.randomUUID().toString();
        }
        MessageDigest m = MessageDigest.getInstance("MD5");
        m.update(message.getBytes("UTF-8"), 0, message.length());
        byte[] sum = m.digest();
        BigInteger messageAsNumber = new BigInteger(1, sum);
        String md5String = messageAsNumber.toString(16);
        while (md5String.length() < 32) {
            md5String = "0" + md5String;
        }
        return "0x" + md5String.substring(0, 16);
    }
public void storeModule(OWLModuleManager manager, Module module, URI physicalURI, OWLModuleFormat moduleFormat) throws ModuleStorageException, UnknownModuleException {
        try {
            OutputStream os;
            if (!physicalURI.isAbsolute()) {
                throw new ModuleStorageException("Physical URI must be absolute: " + physicalURI);
            }
            if (physicalURI.getScheme().equals("file")) {
                File file = new File(physicalURI);
                file.getParentFile().mkdirs();
                os = new FileOutputStream(file);
            } else {
                URL url = physicalURI.toURL();
                URLConnection conn = url.openConnection();
                os = conn.getOutputStream();
            }
            Writer w = new BufferedWriter(new OutputStreamWriter(os));
            storeModule(manager, module, w, moduleFormat);
        } catch (IOException e) {
            throw new ModuleStorageException(e);
        }
    }
private void btnRegisterActionPerformed(java.awt.event.ActionEvent evt) {
        String username = txtUsername.getText();
        String pass = new String(txtPassword.getPassword());
        String password = null;
        Preferences p = NbPreferences.root().node("/org/chartsy/register");
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(new String(txtPassword.getPassword()).getBytes());
            BigInteger hash = new BigInteger(1, md5.digest());
            password = hash.toString(16);
        } catch (NoSuchAlgorithmException ex) {
            LOG.log(Level.SEVERE, null, ex);
        }
        try {
            lblMessage.setText("Checking registration ...");
            btnRegister.setEnabled(false);
            btnRemind.setEnabled(false);
            HttpClient client = ProxyManager.getDefault().getHttpClient();
            GetMethod method = new GetMethod(NbBundle.getMessage(RegisterForm.class, "CheckReg_URL"));
            method.setQueryString(new NameValuePair[] { new NameValuePair("username", username), new NameValuePair("password", password) });
            client.executeMethod(method);
            BufferedReader br = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream()));
            boolean chartsyRegistred = false;
            String name = null;
            if (br != null) {
                String firstLine = br.readLine();
                if (firstLine.equals("OK")) {
                    chartsyRegistred = true;
                    name = br.readLine();
                    p.putBoolean("registred", true);
                    p.put("name", name);
                    p.put("date", String.valueOf(new Date().getTime()));
                    p.put("username", username);
                    p.put("password", pass);
                }
            }
            int userId = checkStockScanPRORegistration();
            boolean stockScanPRORegistred = userId != 0;
            boolean mrSwingRegistred = stockScanPRORegistred ? true : checkMrSwingRegistration();
            p.putBoolean("mrswingregistred", mrSwingRegistred);
            Preferences prefs = NbPreferences.root().node("/org/chartsy/stockscanpro");
            prefs.putBoolean("stockscanproregistred", stockScanPRORegistred);
            prefs.putInt("stockscanprouser", userId);
            FeaturesPanel.getDefault().hideBanners();
            if (chartsyRegistred) {
                if (name != null) {
                    lblMessage.setText(name + ", thank you for the registration.");
                } else {
                    lblMessage.setText("Thank you for the registration.");
                }
                btnRegister.setVisible(false);
                btnRemind.setText("Close");
                btnRemind.setEnabled(true);
            } else {
                lblMessage.setText("Error, could not register. Check your username and password.");
                btnRegister.setEnabled(true);
                btnRemind.setEnabled(true);
            }
        } catch (IOException ex) {
            LOG.log(Level.SEVERE, null, ex);
        }
    }
public void configureLogging() {
        try {
            PreferenceStore preferences = new PreferenceStore();
            IExtensionRegistry registry = Platform.getExtensionRegistry();
            IExtensionPoint extensionPoint = registry.getExtensionPoint(CorePlugin.LOGGER_PREFERENCES_EXTENSION_POINT);
            IConfigurationElement[] members = extensionPoint.getConfigurationElements();
            for (int i = 0; i < members.length; i++) {
                IConfigurationElement element = members[i];
                if (element.getName().equals("logger")) {
                    if (element.getAttribute("defaultValue") != null) {
                        String[] item = element.getAttribute("name").split(";");
                        for (int x = 0; x < item.length; x++) preferences.setDefault("log4j.logger." + item[x], element.getAttribute("defaultValue"));
                    }
                }
            }
            try {
                URL url = CorePlugin.getDefault().getBundle().getResource("log4j.properties");
                Properties properties = new Properties();
                properties.load(url.openStream());
                for (Iterator iter = properties.keySet().iterator(); iter.hasNext(); ) {
                    String key = (String) iter.next();
                    preferences.setDefault(key, (String) properties.get(key));
                }
                File file = CorePlugin.getDefault().getStateLocation().append("log4j.properties").toFile();
                if (file.exists()) preferences.load(new FileInputStream(file));
            } catch (Exception e) {
                CorePlugin.logException(e);
            }
            Properties properties = new Properties();
            String[] names = preferences.preferenceNames();
            for (int i = 0; i < names.length; i++) properties.put(names[i], preferences.getString(names[i]));
            PropertyConfigurator.configure(properties);
        } catch (Exception e) {
            BasicConfigurator.configure();
            logException(e);
        }
    }
public static void main(String[] args) throws IOException {
        File fileIn = new File("D:\\zz_c\\study2\\src\\study\\io\\A.java");
        InputStream fin = new FileInputStream(fileIn);
        PipedInputStream pin = new PipedInputStream();
        PipedOutputStream pout = new PipedOutputStream();
        pout.connect(pin);
        IoRead i = new IoRead();
        i.setIn(pin);
        File fileOU1 = new File("D:\\zz_c\\study2\\src\\study\\io\\A1.java");
        File fileOU2 = new File("D:\\zz_c\\study2\\src\\study\\io\\A2.java");
        File fileOU3 = new File("D:\\zz_c\\study2\\src\\study\\io\\A3.java");
        i.addOut(new BufferedOutputStream(new FileOutputStream(fileOU1)));
        i.addOut(new BufferedOutputStream(new FileOutputStream(fileOU2)));
        i.addOut(new BufferedOutputStream(new FileOutputStream(fileOU3)));
        PipedInputStream pin2 = new PipedInputStream();
        PipedOutputStream pout2 = new PipedOutputStream();
        i.addOut(pout2);
        pout2.connect(pin2);
        i.start();
        int read;
        try {
            read = fin.read();
            while (read != -1) {
                pout.write(read);
                read = fin.read();
            }
            fin.close();
            pout.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        int c = pin2.read();
        while (c != -1) {
            System.out.print((char) c);
            c = pin2.read();
        }
        pin2.close();
    }
public ValidEPoint[] split(EPoint o, EPoint e1, long v1, EPoint e2) throws MalformedURLException, IOException, NoSuchAlgorithmException, InvalidEPointCertificateException, InvalidKeyException, SignatureException {
        URLConnection u = new URL(url, "action").openConnection();
        OutputStream os;
        InputStream is;
        ValidEPoint[] v = new ValidEPoint[2];
        u.setDoOutput(true);
        u.setDoInput(true);
        u.setAllowUserInteraction(false);
        os = u.getOutputStream();
        os.write(("B=" + URLEncoder.encode(o.toString(), "UTF-8") + "&D=" + Base16.encode(e1.getMD()) + "&F=" + Long.toString(v1) + "&C=" + Base16.encode(e2.getMD())).getBytes());
        os.close();
        is = u.getInputStream();
        v[1] = new ValidEPoint(this, e2, is);
        is.close();
        v[0] = validate(e1);
        return v;
    }
public static byte[] clearPassToUserPassword(String clearpass, HashAlg alg, byte[] salt) {
        if (alg == null) {
            throw new IllegalArgumentException("Invalid hash argorithm.");
        }
        try {
            MessageDigest digester = null;
            StringBuilder resultInText = new StringBuilder();
            switch(alg) {
                case MD5:
                    resultInText.append("{MD5}");
                    digester = MessageDigest.getInstance("MD5");
                    break;
                case SMD5:
                    resultInText.append("{SMD5}");
                    digester = MessageDigest.getInstance("MD5");
                    break;
                case SHA:
                    resultInText.append("{SHA}");
                    digester = MessageDigest.getInstance("SHA");
                    break;
                case SSHA:
                    resultInText.append("{SSHA}");
                    digester = MessageDigest.getInstance("SHA");
                    break;
                default:
                    break;
            }
            digester.reset();
            digester.update(clearpass.getBytes(DEFAULT_ENCODING));
            byte[] hash = null;
            if (salt != null && (alg == HashAlg.SMD5 || alg == HashAlg.SSHA)) {
                digester.update(salt);
                hash = ArrayUtils.addAll(digester.digest(), salt);
            } else {
                hash = digester.digest();
            }
            resultInText.append(new String(Base64.encodeBase64(hash), DEFAULT_ENCODING));
            return resultInText.toString().getBytes(DEFAULT_ENCODING);
        } catch (UnsupportedEncodingException uee) {
            log.warn("Error occurred while hashing password ", uee);
            return new byte[0];
        } catch (java.security.NoSuchAlgorithmException nse) {
            log.warn("Error occurred while hashing password ", nse);
            return new byte[0];
        }
    }
public static String sendGetData(URL url, Hashtable<String, String> data) throws IOException {
        StringBuilder outStringBuilder = new StringBuilder();
        if (data != null) {
            for (Entry<String, String> entry : data.entrySet()) {
                outStringBuilder.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
                outStringBuilder.append("=");
                outStringBuilder.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
                outStringBuilder.append("&");
            }
        }
        URL innerURL = new URL(url.toString() + "?" + outStringBuilder.toString());
        System.out.println("URL: " + innerURL);
        URLConnection urlConnection = innerURL.openConnection();
        urlConnection.connect();
        StringBuilder inStringBuilder = new StringBuilder();
        BufferedReader reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
        Scanner inputScanner = new Scanner(urlConnection.getInputStream());
        while (inputScanner.hasNext()) {
            inStringBuilder.append(inputScanner.next() + " ");
        }
        inputScanner.close();
        reader.close();
        return inStringBuilder.toString();
    }
public static void copy(File source, File dest) throws java.io.IOException {
        FileChannel in = null, out = null;
        try {
            in = new FileInputStream(source).getChannel();
            out = new FileOutputStream(dest).getChannel();
            long size = in.size();
            MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size);
            out.write(buf);
        } finally {
            if (in != null) in.close();
            if (out != null) out.close();
        }
    }
public static void main(String args[]) {
        int[] mas = { 3, 5, 6, 9, 1, -3, -4, -88 };
        int sort = 0;
        for (int j = 0; j < (mas.length); j++) {
            for (int i = 0; i < mas.length - 1; i++) {
                if (mas[i] > mas[i + 1]) {
                    sort = mas[i];
                    mas[i] = mas[i + 1];
                    mas[i + 1] = sort;
                }
            }
        }
        for (int i = 0; i < mas.length; i++) {
            System.out.print(" " + mas[i]);
        }
    }
public synchronized String encrypt(String plaintext) {
        MessageDigest md = null;
        String hash = null;
        try {
            md = MessageDigest.getInstance("SHA");
            md.update(plaintext.getBytes("UTF-8"));
            byte raw[] = md.digest();
            hash = (new BASE64Encoder()).encode(raw);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return hash;
    }
public void removeDownload() {
        synchronized (mDownloadMgr) {
            int rowCount = mDownloadTable.getSelectedRowCount();
            if (rowCount <= 0) return;
            int[] rows = mDownloadTable.getSelectedRows();
            int[] orderedRows = new int[rows.length];
            Vector downloadFilesToRemove = new Vector();
            for (int i = 0; i < rowCount; i++) {
                int row = rows[i];
                if (row >= mDownloadMgr.getDownloadCount()) return;
                orderedRows[i] = mDownloadSorter.indexes[row];
            }
            mDownloadTable.removeRowSelectionInterval(0, mDownloadTable.getRowCount() - 1);
            for (int i = orderedRows.length - 1; i > 0; i--) {
                for (int j = 0; j < i; j++) {
                    if (orderedRows[j] > orderedRows[j + 1]) {
                        int tmp = orderedRows[j];
                        orderedRows[j] = orderedRows[j + 1];
                        orderedRows[j + 1] = tmp;
                    }
                }
            }
            for (int i = orderedRows.length - 1; i >= 0; i--) {
                mDownloadMgr.removeDownload(orderedRows[i]);
            }
            mainFrame.refreshAllActions();
        }
    }
public static void main(String[] args) {
        FTPClient f = new FTPClient();
        String host = "ftpdatos.aemet.es";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
        final String datestamp = sdf.format(new Date());
        System.out.println(datestamp);
        String pathname = "datos_observacion/observaciones_diezminutales/" + datestamp + "_diezminutales/";
        try {
            InetAddress server = InetAddress.getByName(host);
            f.connect(server);
            String username = "anonymous";
            String password = "a@b.c";
            f.login(username, password);
            FTPFile[] files = f.listFiles(pathname, new FTPFileFilter() {

                @Override
                public boolean accept(FTPFile file) {
                    return file.getName().startsWith(datestamp);
                }
            });
            FTPFile file = files[files.length - 2];
            f.setFileTransferMode(FTPClient.BINARY_FILE_TYPE);
            boolean download = false;
            String remote = pathname + "/" + file.getName();
            if (download) {
                File out = new File("/home/randres/Desktop/" + file.getName());
                FileOutputStream fout = new FileOutputStream(out);
                System.out.println(f.retrieveFile(remote, fout));
                fout.flush();
                fout.close();
            } else {
                GZIPInputStream gzipin = new GZIPInputStream(f.retrieveFileStream(remote));
                LineNumberReader lreader = new LineNumberReader(new InputStreamReader(gzipin, "Cp1250"));
                String line = null;
                while ((line = lreader.readLine()) != null) {
                    Aeminuto.processLine(line);
                }
                lreader.close();
            }
            f.disconnect();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
public void testSimpleQuery() throws Exception {
        JCRNodeSource dummySource = (JCRNodeSource) resolveSource(BASE_URL + "users/alexander.klimetschek");
        assertNotNull(dummySource);
        OutputStream os = ((ModifiableSource) dummySource).getOutputStream();
        assertNotNull(os);
        String dummyContent = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><user><id>alexander</id><teamspace>cyclr</teamspace><teamspace>mindquarryTooLong</teamspace></user>";
        os.write(dummyContent.getBytes());
        os.flush();
        os.close();
        JCRNodeSource source = (JCRNodeSource) resolveSource(BASE_URL + "users/bastian");
        assertNotNull(source);
        os = ((ModifiableSource) source).getOutputStream();
        assertNotNull(os);
        String content = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><user><id>bastian</id><teamspace>mindquarry</teamspace></user>";
        os.write(content.getBytes());
        os.flush();
        os.close();
        QueryResultSource qResult = (QueryResultSource) resolveSource(BASE_URL + "users?/*[.//user/teamspace='mindquarry']");
        assertNotNull(qResult);
        Collection results = qResult.getChildren();
        assertEquals(1, results.size());
        Iterator it = results.iterator();
        JCRNodeSource rSrc = (JCRNodeSource) it.next();
        InputStream rSrcIn = rSrc.getInputStream();
        ByteArrayOutputStream actualOut = new ByteArrayOutputStream();
        IOUtils.copy(rSrcIn, actualOut);
        rSrcIn.close();
        assertEquals(content, actualOut.toString());
        actualOut.close();
        rSrc.delete();
    }