semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public static int[] sortDescending(double input[]) {
        int[] order = new int[input.length];
        for (int i = 0; i < order.length; i++) order[i] = i;
        for (int i = input.length; --i >= 0; ) {
            for (int j = 0; j < i; j++) {
                if (input[j] < input[j + 1]) {
                    double mem = input[j];
                    input[j] = input[j + 1];
                    input[j + 1] = mem;
                    int id = order[j];
                    order[j] = order[j + 1];
                    order[j + 1] = id;
                }
            }
        }
        return order;
    }
private void openConnection() throws IOException {
        connection = (HttpURLConnection) url.openConnection(Global.getProxy());
        connection.setDoInput(true);
        connection.setDoOutput(true);
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "text/xml; charset=" + XmlRpcMessages.getString("XmlRpcClient.Encoding"));
        if (requestProperties != null) {
            for (Iterator propertyNames = requestProperties.keySet().iterator(); propertyNames.hasNext(); ) {
                String propertyName = (String) propertyNames.next();
                connection.setRequestProperty(propertyName, (String) requestProperties.get(propertyName));
            }
        }
    }
public static void copyFile(final File sourceFile, final File destFile) throws IOException {
        if (!destFile.exists()) destFile.createNewFile();
        FileChannel source = null;
        FileChannel destination = null;
        try {
            source = new FileInputStream(sourceFile).getChannel();
            destination = new FileOutputStream(destFile).getChannel();
            destination.transferFrom(source, 0, source.size());
        } finally {
            if (source != null) source.close();
            if (destination != null) destination.close();
        }
    }
public static String hash(final String s) {
        if (s == null || s.length() == 0) return null;
        try {
            final MessageDigest hashEngine = MessageDigest.getInstance("SHA-1");
            hashEngine.update(s.getBytes("iso-8859-1"), 0, s.length());
            return convertToHex(hashEngine.digest());
        } catch (final Exception e) {
            return null;
        }
    }
public InputStream getDaoConfig(String connectionType) throws IOException {
        URL url = null;
        InputStream inStream = null;
        if (connectionType.equals(SQL.ORACLE)) {
            url = com.apelon.selext.db.config.MatchLoadConfig.class.getResource("oracle.xml");
        } else if (connectionType.equals(SQL.SQL2K)) {
            url = com.apelon.selext.db.config.MatchLoadConfig.class.getResource("sql2k.xml");
        } else if (connectionType.equals(SQL.CACHE)) {
            url = com.apelon.selext.db.config.MatchLoadConfig.class.getResource("cache.xml");
        } else if (connectionType.equals(SQL.DB2)) {
            url = com.apelon.selext.db.config.MatchLoadConfig.class.getResource("db2.xml");
        } else {
            Categories.dataXml().error("* Problem: Unknown connection type: " + connectionType);
        }
        try {
            inStream = url.openStream();
        } catch (NullPointerException npe) {
            Categories.dataXml().error("* Problem: Undefined resource URL: " + npe.getMessage());
            throw npe;
        }
        return inStream;
    }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String uid = request.getParameter("id");
        String pwd = request.getParameter("pwd");
        String email = request.getParameter("email");
        String sid = request.getParameter("sid");
        System.out.println(uid);
        System.out.println(pwd);
        System.out.println(email);
        System.out.println(sid);
        DBconn dbc = new DBconn();
        Connection conn;
        PreparedStatement pst;
        Statement st;
        conn = dbc.getConnection();
        PasswordService ps = PasswordService.getInstance();
        String hash = "";
        try {
            hash = ps.encrypt(pwd);
        } catch (Exception e2) {
            e2.printStackTrace();
        }
        String sql = "insert into HP_ADMINISTRATOR.STAFF_REGISTRATION values (?,?,?,?)";
        try {
            pst = conn.prepareStatement(sql);
            pst.setString(1, uid);
            pst.setString(2, hash);
            pst.setString(3, email);
            pst.setString(4, sid);
            System.out.println(pst.toString());
            pst.executeUpdate();
        } catch (SQLException e) {
            e.printStackTrace();
            try {
                conn.rollback();
                conn.setAutoCommit(true);
            } catch (SQLException e1) {
                e1.printStackTrace();
            }
        }
        response.sendRedirect("AdminControlStaff.jsp");
    }
public static InputStream openStream(URL url) {
        try {
            URLConnection connection = url.openConnection();
            connection.setUseCaches(false);
            return connection.getInputStream();
        } catch (IOException e) {
            throw new IORuntimeException(e);
        }
    }
public static void main(String[] argz) {
        int X, Y, Z;
        X = 256;
        Y = 256;
        Z = 256;
        try {
            String work_folder = "C:\\Documents and Settings\\Entheogen\\My Documents\\school\\jung\\vol_data\\CT_HEAD3";
            FileOutputStream out_stream = new FileOutputStream(new File(work_folder + "\\converted.dat"));
            FileChannel out = out_stream.getChannel();
            String f_name = "head256.raw";
            File file = new File(work_folder + "\\" + f_name);
            FileChannel in = new FileInputStream(file).getChannel();
            ByteBuffer buffa = BufferUtil.newByteBuffer((int) file.length());
            in.read(buffa);
            in.close();
            int N = 256;
            FloatBuffer output_data = BufferUtil.newFloatBuffer(N * N * N);
            float min = Float.MAX_VALUE;
            for (int i = 0, j = 0; i < buffa.capacity(); i++, j++) {
                byte c = buffa.get(i);
                min = Math.min(min, (float) (c));
                output_data.put((float) (c));
            }
            for (int i = 0; i < Y - X; ++i) {
                for (int j = 0; j < Y; ++j) {
                    for (int k = 0; k < Z; ++k) {
                        output_data.put(min);
                    }
                }
            }
            output_data.rewind();
            System.out.println("size of output_data = " + Integer.toString(output_data.capacity()));
            out.write(BufferUtil.copyFloatBufferAsByteBuffer(output_data));
            ByteBuffer buffa2 = BufferUtil.newByteBuffer(2);
            buffa2.put((byte) '.');
            out.close();
        } catch (Exception exc) {
            exc.printStackTrace();
        }
    }
public XlsBook(String path) throws IOException {
        boolean isHttp = path.startsWith("http://");
        InputStream is = null;
        if (isHttp) {
            URL url = new URL(path);
            is = url.openStream();
        } else {
            File file = new File(path);
            is = new FileInputStream(file);
        }
        workbook = XlsBook.createWorkbook(is);
        is.close();
    }
public static String getHighlightBaseLib() throws Exception {
        StringBuffer highlightKey = new StringBuffer();
        highlightKey.append("<c color=\"" + COLOR_BASELIB + "\">\n\t");
        URL url = AbstractRunner.class.getResource("baselib.js");
        if (url != null) {
            InputStream is = url.openStream();
            InputStreamReader reader = new InputStreamReader(is, "UTF-8");
            BufferedReader bfReader = new BufferedReader(reader);
            String tmp = null;
            do {
                tmp = bfReader.readLine();
                if (tmp != null) {
                    if (tmp.indexOf("function") > -1) {
                        highlightKey.append("<w>" + (tmp.substring(tmp.indexOf("function") + 8, tmp.indexOf("(")).trim()) + "</w>\n\t");
                    }
                }
            } while (tmp != null);
            bfReader.close();
            reader.close();
            is.close();
        }
        highlightKey.append("</c>");
        return highlightKey.toString();
    }
public void update() {
        Authenticator.setDefault(new MyAuthenticator());
        URL url = null;
        try {
            url = new URL("http://trade.gigabass.de/update/update.php");
        } catch (MalformedURLException e) {
            handleException(e);
            return;
        }
        URLConnection conn;
        try {
            conn = url.openConnection();
        } catch (IOException e) {
            handleException(e);
            return;
        }
        conn.setDoOutput(true);
        OutputStreamWriter wr = null;
        try {
            wr = new OutputStreamWriter(conn.getOutputStream());
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            wr.write("sql=" + URLEncoder.encode(sql, "UTF-8") + "\n");
            wr.flush();
        } catch (IOException e) {
            handleException(e);
        }
        BufferedReader rd = null;
        try {
            rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            while ((line = rd.readLine()) != null) {
            }
        } catch (IOException e) {
            handleException(e);
        }
        try {
            wr.close();
        } catch (IOException e) {
            handleException(e);
        }
        try {
            rd.close();
        } catch (IOException e) {
            handleException(e);
        }
    }
public void unzip(String zipFileName, String outputDirectory) throws Exception {
        ZipInputStream in = new ZipInputStream(new FileInputStream(zipFileName));
        ZipEntry z;
        while ((z = in.getNextEntry()) != null) {
            System.out.println("unziping " + z.getName());
            if (z.isDirectory()) {
                String name = z.getName();
                name = name.substring(0, name.length() - 1);
                File f = new File(outputDirectory + File.separator + name);
                f.mkdir();
                System.out.println("mkdir " + outputDirectory + File.separator + name);
            } else {
                File f = new File(outputDirectory + File.separator + z.getName());
                f.createNewFile();
                FileOutputStream out = new FileOutputStream(f);
                int b;
                while ((b = in.read()) != -1) out.write(b);
                out.close();
            }
        }
        in.close();
    }
public String get(String question) {
        try {
            System.out.println(url + question);
            URL urlonlineserver = new URL(url + question);
            BufferedReader in = new BufferedReader(new InputStreamReader(urlonlineserver.openStream()));
            String inputLine;
            String returnstring = "";
            while ((inputLine = in.readLine()) != null) returnstring += inputLine;
            in.close();
            return returnstring;
        } catch (IOException e) {
            return "";
        }
    }
public Reader transform(Reader reader, Map<String, Object> parameterMap) {
        try {
            File file = File.createTempFile("srx2", ".srx");
            file.deleteOnExit();
            Writer writer = getWriter(getFileOutputStream(file.getAbsolutePath()));
            transform(reader, writer, parameterMap);
            writer.close();
            Reader resultReader = getReader(getFileInputStream(file.getAbsolutePath()));
            return resultReader;
        } catch (IOException e) {
            throw new IORuntimeException(e);
        }
    }
HttpRepository(Path path) throws IOException {
        super(path);
        this.url = new URL(path.toURLString());
        HttpURLConnection.setFollowRedirects(true);
        this.connection = (HttpURLConnection) url.openConnection();
        this.ns = Names.getNamespace(path);
    }
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        try {
            StringBuilder sb = new StringBuilder();
            URL url = new URL("https://ajax.googleapis.com/ajax/services/search/news?v=1.0&q=google");
            URLConnection connection = url.openConnection();
            String line;
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            while ((line = reader.readLine()) != null) sb.append(line);
            JSONObject json = new JSONObject(sb.toString());
            sb.setLength(0);
            JSONObject responseData = (JSONObject) json.get("responseData");
            JSONArray results = (JSONArray) responseData.get("results");
            for (int i = 0; i < results.length(); i++) {
                JSONObject result = (JSONObject) results.get(i);
                sb.append(result.get("title")).append("\n\n");
            }
            TextView tv = (TextView) findViewById(R.id.textView);
            tv.setText(sb.toString());
        } catch (Exception e) {
        }
    }
public static int getFilesize(String theURL) {
        URL url;
        URLConnection conn;
        int size = -1;
        try {
            url = new URL(theURL);
            conn = url.openConnection();
            conn.setRequestProperty("User-Agent", Main.USER_AGENT);
            conn.setConnectTimeout(Main.CONNECT_TIMEOUT * 2);
            conn.setReadTimeout(Main.READ_TIMEOUT * 2);
            size = conn.getContentLength();
            conn.getInputStream().close();
        } catch (FileNotFoundException fnfe) {
            return -2;
        } catch (ConnectException ce) {
            return -3;
        } catch (ProtocolException fpe) {
            return -2;
        } catch (IOException ioe) {
            return -2;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return size;
    }
private void copyFile(File in, File out) throws IOException {
        FileChannel inChannel = new FileInputStream(in).getChannel();
        FileChannel outChannel = new FileOutputStream(out).getChannel();
        try {
            inChannel.transferTo(0, inChannel.size(), outChannel);
        } catch (IOException e) {
            throw e;
        } finally {
            if (inChannel != null) inChannel.close();
            if (outChannel != null) outChannel.close();
        }
    }
public static String buildUserPassword(String password) {
        String result = "";
        MessageDigest md;
        try {
            md = MessageDigest.getInstance("MD5");
            md.update(password.getBytes("UTF8"));
            byte[] hash = md.digest();
            for (int i = 0; i < hash.length; i++) {
                int hexValue = hash[i] & 0xFF;
                if (hexValue < 16) {
                    result = result + "0";
                }
                result = result + Integer.toString(hexValue, 16);
            }
            logger.debug("Users'password MD5 Digest: " + result);
        } catch (NoSuchAlgorithmException ex) {
            logger.error(ex.getMessage());
            ex.printStackTrace();
        } catch (UnsupportedEncodingException ex) {
            logger.error(ex.getMessage());
            ex.printStackTrace();
        }
        return result;
    }
public static String plainToMD(LoggerCollection loggerCol, String input) {
        byte[] byteHash = null;
        MessageDigest md = null;
        StringBuilder md5result = new StringBuilder();
        try {
            md = MessageDigest.getInstance("MD5");
            md.reset();
            md.update(input.getBytes());
            byteHash = md.digest();
            for (int i = 0; i < byteHash.length; i++) {
                md5result.append(Integer.toHexString(0xFF & byteHash[i]));
            }
        } catch (NoSuchAlgorithmException ex) {
            loggerCol.logException(CLASSDEBUG, "de.searchworkorange.lib.misc.hash.MD5Hash", Level.FATAL, ex);
        }
        return (md5result.toString());
    }
public void actionPerformed(ActionEvent e) {
        if (e.getSource() == cancel) {
            email.setText("");
            name.setText("");
            category.setSelectedIndex(0);
            subject.setText("");
            message.setText("");
            setVisible(false);
        } else {
            StringBuffer errors = new StringBuffer();
            if (email.getText().trim().equals("")) errors.append("El campo 'Email' es obligatorio<br/>");
            if (name.getText().trim().equals("")) errors.append("El campo 'Nombre' es obligatorio<br/>");
            if (subject.getText().trim().equals("")) errors.append("El campo 'T�tulo' es obligatorio<br/>");
            if (message.getText().trim().equals("")) errors.append("No hay conrtenido en el mensaje<br/>");
            if (errors.length() > 0) {
                JOptionPane.showMessageDialog(this, "<html><b>Error</b><br/>" + errors.toString() + "</html>", "Error", JOptionPane.ERROR_MESSAGE);
            } else {
                try {
                    StringBuffer params = new StringBuffer();
                    params.append("name=").append(URLEncoder.encode(name.getText(), "UTF-8")).append("&category=").append(URLEncoder.encode((String) category.getSelectedItem(), "UTF-8")).append("&title=").append(URLEncoder.encode(subject.getText(), "UTF-8")).append("&email=").append(URLEncoder.encode(email.getText(), "UTF-8")).append("&id=").append(URLEncoder.encode(MainWindow.getUserPreferences().getUniqueId() + "", "UTF-8")).append("&body=").append(URLEncoder.encode(message.getText(), "UTF-8"));
                    URL url = new URL("http://www.cronopista.com/diccionario2/sendMessage.php");
                    URLConnection connection = url.openConnection();
                    Utils.setupProxy(connection);
                    connection.setDoOutput(true);
                    OutputStreamWriter out = new OutputStreamWriter(connection.getOutputStream());
                    out.write(params.toString());
                    out.close();
                    BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                    String decodedString;
                    while ((decodedString = in.readLine()) != null) {
                        System.out.println(decodedString);
                    }
                    in.close();
                    email.setText("");
                    name.setText("");
                    category.setSelectedIndex(0);
                    subject.setText("");
                    message.setText("");
                    setVisible(false);
                } catch (Exception ex) {
                    JOptionPane.showMessageDialog(this, "<html><b>Error</b><br/>Ha ocurrido un error enviando tu mensaje.<br/>" + "Por favor, int�ntalo m�s tarde o ponte en contacto conmigo a trav�s de www.cronopista.com</html>", "Error", JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    }
public static String loadResource(String resource) {
        URL url = ClassLoader.getSystemResource("resources/" + resource);
        StringBuffer buffer = new StringBuffer();
        if (url == null) {
            ErrorMessage.handle(new NullPointerException("URL for resources/" + resource + " not found"));
        } else {
            try {
                BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
                String line = null;
                while ((line = reader.readLine()) != null) {
                    buffer.append(line + "\n");
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return buffer.toString();
    }
private void redownloadResource(SchemaResource resource) {
        if (_redownloadSet != null) {
            if (_redownloadSet.contains(resource)) return;
            _redownloadSet.add(resource);
        }
        String filename = resource.getFilename();
        String schemaLocation = resource.getSchemaLocation();
        String digest = null;
        if (schemaLocation == null || filename == null) return;
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
        try {
            URL url = new URL(schemaLocation);
            URLConnection conn = url.openConnection();
            conn.addRequestProperty("User-Agent", USER_AGENT);
            conn.addRequestProperty("Accept", "application/xml, text/xml, */*");
            DigestInputStream input = digestInputStream(conn.getInputStream());
            IOUtil.copyCompletely(input, buffer);
            digest = HexBin.bytesToString(input.getMessageDigest().digest());
        } catch (Exception e) {
            warning("Could not copy remote resource " + schemaLocation + ":" + e.getMessage());
            return;
        }
        if (digest.equals(resource.getSha1()) && fileExists(filename)) {
            warning("Resource " + filename + " is unchanged from " + schemaLocation + ".");
            return;
        }
        try {
            InputStream source = new ByteArrayInputStream(buffer.toByteArray());
            writeInputStreamToFile(source, filename);
        } catch (IOException e) {
            warning("Could not write to file " + filename + " for " + schemaLocation + ":" + e.getMessage());
            return;
        }
        warning("Refreshed " + filename + " from " + schemaLocation);
    }
public byte[] getDigest(OMProcessingInstruction pi, String digestAlgorithm) throws OMException {
        byte[] digest = new byte[0];
        try {
            MessageDigest md = MessageDigest.getInstance(digestAlgorithm);
            md.update((byte) 0);
            md.update((byte) 0);
            md.update((byte) 0);
            md.update((byte) 7);
            md.update(pi.getTarget().getBytes("UnicodeBigUnmarked"));
            md.update((byte) 0);
            md.update((byte) 0);
            md.update(pi.getValue().getBytes("UnicodeBigUnmarked"));
            digest = md.digest();
        } catch (NoSuchAlgorithmException e) {
            throw new OMException(e);
        } catch (UnsupportedEncodingException e) {
            throw new OMException(e);
        }
        return digest;
    }
public byte[] getDigest(OMAttribute attribute, String digestAlgorithm) throws OMException {
        byte[] digest = new byte[0];
        if (!(attribute.getLocalName().equals("xmlns") || attribute.getLocalName().startsWith("xmlns:"))) try {
            MessageDigest md = MessageDigest.getInstance(digestAlgorithm);
            md.update((byte) 0);
            md.update((byte) 0);
            md.update((byte) 0);
            md.update((byte) 2);
            md.update(getExpandedName(attribute).getBytes("UnicodeBigUnmarked"));
            md.update((byte) 0);
            md.update((byte) 0);
            md.update(attribute.getAttributeValue().getBytes("UnicodeBigUnmarked"));
            digest = md.digest();
        } catch (NoSuchAlgorithmException e) {
            throw new OMException(e);
        } catch (UnsupportedEncodingException e) {
            throw new OMException(e);
        }
        return digest;
    }
public byte[] getDigest(OMText text, String digestAlgorithm) throws OMException {
        byte[] digest = new byte[0];
        try {
            MessageDigest md = MessageDigest.getInstance(digestAlgorithm);
            md.update((byte) 0);
            md.update((byte) 0);
            md.update((byte) 0);
            md.update((byte) 3);
            md.update(text.getText().getBytes("UnicodeBigUnmarked"));
            digest = md.digest();
        } catch (NoSuchAlgorithmException e) {
            throw new OMException(e);
        } catch (UnsupportedEncodingException e) {
            throw new OMException(e);
        }
        return digest;
    }