semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public static void main(String[] args) throws IOException {
        PostParameter a1 = new PostParameter("v", Utils.encode("1.0"));
        PostParameter a2 = new PostParameter("api_key", Utils.encode(RenRenConstant.apiKey));
        PostParameter a3 = new PostParameter("method", Utils.encode("feed.publishTemplatizedAction"));
        PostParameter a4 = new PostParameter("call_id", System.nanoTime());
        PostParameter a5 = new PostParameter("session_key", Utils.encode("5.b2ca405eef80b4da1f68d0df64e471be.86400.1298372400-350727914"));
        PostParameter a8 = new PostParameter("format", Utils.encode("JSON"));
        PostParameter a9 = new PostParameter("template_id", Utils.encode("1"));
        PostParameter a10 = new PostParameter("title_data", Utils.encode("\"conteng\":\"xkt\""));
        PostParameter a11 = new PostParameter("body_data", Utils.encode("\"conteng\":\"xkt\""));
        RenRenPostParameters ps = new RenRenPostParameters(Utils.encode(RenRenConstant.secret));
        ps.addParameter(a1);
        ps.addParameter(a2);
        ps.addParameter(a3);
        ps.addParameter(a4);
        ps.addParameter(a5);
        ps.addParameter(a8);
        ps.addParameter(a9);
        ps.addParameter(a10);
        ps.addParameter(a11);
        System.out.println(RenRenConstant.apiUrl + "?" + ps.generateUrl());
        URL url = new URL(RenRenConstant.apiUrl + "?" + ps.generateUrl());
        HttpURLConnection request = (HttpURLConnection) url.openConnection();
        request.setDoOutput(true);
        request.setRequestMethod("POST");
        System.out.println("Sending request...");
        request.connect();
        System.out.println("Response: " + request.getResponseCode() + " " + request.getResponseMessage());
        BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()));
        String b = null;
        while ((b = reader.readLine()) != null) {
            System.out.println(b);
        }
    }
@Override
    public void end() {
        m_zipFormatter.end();
        IOUtils.closeQuietly(m_outputStream);
        final FTPClient ftp = new FTPClient();
        FileInputStream fis = null;
        try {
            if (m_url.getPort() == -1 || m_url.getPort() == 0 || m_url.getPort() == m_url.getDefaultPort()) {
                ftp.connect(m_url.getHost());
            } else {
                ftp.connect(m_url.getHost(), m_url.getPort());
            }
            if (m_url.getUserInfo() != null && m_url.getUserInfo().length() > 0) {
                final String[] userInfo = m_url.getUserInfo().split(":", 2);
                ftp.login(userInfo[0], userInfo[1]);
            } else {
                ftp.login("anonymous", "opennmsftp@");
            }
            int reply = ftp.getReplyCode();
            if (!FTPReply.isPositiveCompletion(reply)) {
                ftp.disconnect();
                LogUtils.errorf(this, "FTP server refused connection.");
                return;
            }
            String path = m_url.getPath();
            if (path.endsWith("/")) {
                LogUtils.errorf(this, "Your FTP URL must specify a filename.");
                return;
            }
            File f = new File(path);
            path = f.getParent();
            if (!ftp.changeWorkingDirectory(path)) {
                LogUtils.infof(this, "unable to change working directory to %s", path);
                return;
            }
            LogUtils.infof(this, "uploading %s to %s", f.getName(), path);
            ftp.setFileType(FTP.BINARY_FILE_TYPE);
            fis = new FileInputStream(m_zipFile);
            if (!ftp.storeFile(f.getName(), fis)) {
                LogUtils.infof(this, "unable to store file");
                return;
            }
            LogUtils.infof(this, "finished uploading");
        } catch (final Exception e) {
            LogUtils.errorf(this, e, "Unable to FTP file to %s", m_url);
        } finally {
            IOUtils.closeQuietly(fis);
            if (ftp.isConnected()) {
                try {
                    ftp.disconnect();
                } catch (IOException ioe) {
                }
            }
        }
    }
public void doAction(HttpServletRequest request, HttpServletResponse response) throws Exception {
        String attachmentName = request.getParameter("attachment");
        String virtualWiki = getVirtualWiki(request);
        File uploadPath = getEnvironment().uploadPath(virtualWiki, attachmentName);
        response.reset();
        response.setHeader("Content-Disposition", getEnvironment().getStringSetting(Environment.PROPERTY_ATTACHMENT_TYPE) + ";filename=" + attachmentName + ";");
        int dotIndex = attachmentName.indexOf('.');
        if (dotIndex >= 0 && dotIndex < attachmentName.length() - 1) {
            String extension = attachmentName.substring(attachmentName.lastIndexOf('.') + 1);
            logger.fine("Extension: " + extension);
            String mimetype = (String) getMimeByExtension().get(extension.toLowerCase());
            logger.fine("MIME: " + mimetype);
            if (mimetype != null) {
                logger.fine("Setting content type to: " + mimetype);
                response.setContentType(mimetype);
            }
        }
        FileInputStream in = null;
        ServletOutputStream out = null;
        try {
            in = new FileInputStream(uploadPath);
            out = response.getOutputStream();
            IOUtils.copy(in, out);
            out.flush();
        } finally {
            IOUtils.closeQuietly(in);
            IOUtils.closeQuietly(out);
        }
    }
public static String encryptPassword(String password) {
        try {
            MessageDigest digest = java.security.MessageDigest.getInstance("SHA1");
            digest.update(password.getBytes("UTF-8"));
            byte[] hash = digest.digest();
            StringBuffer buf = new StringBuffer();
            for (int i = 0; i < hash.length; i++) {
                int halfbyte = (hash[i] >>> 4) & 0x0F;
                int two_halfs = 0;
                do {
                    if ((0 <= halfbyte) && (halfbyte <= 9)) {
                        buf.append((char) ('0' + halfbyte));
                    } else {
                        buf.append((char) ('a' + (halfbyte - 10)));
                    }
                    halfbyte = hash[i] & 0x0F;
                } while (two_halfs++ < 1);
            }
            return buf.toString();
        } catch (Exception e) {
        }
        return null;
    }
void copy(String source_name, String dest_name) throws IOException {
            File source_file = new File(source_name);
            File destination_file = new File(dest_name);
            FileInputStream source = null;
            FileOutputStream destination = null;
            byte[] buffer;
            int bytes_read;
            try {
                if (!source_file.exists() || !source_file.isFile()) {
                    throw new FileCopyException("FileCopy: no such source file: " + source_name);
                }
                if (!source_file.canRead()) {
                    throw new FileCopyException("FileCopy: source file " + "is unreadable: " + source_name);
                }
                if (!destination_file.exists()) {
                    File parentdir = parent(destination_file);
                    if (!parentdir.exists()) {
                        throw new FileCopyException("FileCopy: destination " + "directory doesn't exist: " + dest_name);
                    }
                    if (!parentdir.canWrite()) {
                        throw new FileCopyException("FileCopy: destination " + "directory is unwriteable: " + dest_name);
                    }
                }
                source = new FileInputStream(source_file);
                destination = new FileOutputStream(destination_file);
                buffer = new byte[1024];
                while (true) {
                    bytes_read = source.read(buffer);
                    if (bytes_read == -1) {
                        break;
                    }
                    destination.write(buffer, 0, bytes_read);
                }
            } finally {
                if (source != null) {
                    try {
                        source.close();
                    } catch (IOException e) {
                    }
                }
                if (destination != null) {
                    try {
                        destination.close();
                    } catch (IOException e) {
                    }
                }
            }
        }
public String login() {
        System.out.println("Logging in to LOLA");
        try {
            String data = URLEncoder.encode("email", "UTF-8") + "=" + URLEncoder.encode(get_email(), "UTF-8");
            data += "&" + URLEncoder.encode("pw", "UTF-8") + "=" + URLEncoder.encode(get_pw(), "UTF-8");
            URL url = new URL(URL_LOLA + FILE_LOGIN);
            URLConnection conn = url.openConnection();
            conn.setDoOutput(true);
            OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
            wr.write(data);
            wr.flush();
            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line, sessid;
            line = rd.readLine();
            sessid = get_sessid(line);
            this.set_session(sessid);
            wr.close();
            rd.close();
            return sessid;
        } catch (Exception e) {
            System.out.println("Login Error");
            return "";
        }
    }
public void create_list() {
        try {
            String data = URLEncoder.encode("PHPSESSID", "UTF-8") + "=" + URLEncoder.encode(this.get_session(), "UTF-8");
            URL url = new URL(URL_LOLA + FILE_CREATE_LIST);
            URLConnection conn = url.openConnection();
            conn.setDoOutput(true);
            OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
            wr.write(data);
            wr.flush();
            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            line = rd.readLine();
            wr.close();
            rd.close();
            System.out.println("Gene list saved in LOLA");
        } catch (Exception e) {
            System.out.println("error in createList()");
            e.printStackTrace();
        }
    }
static void reopen(MJIEnv env, int objref) throws IOException {
        int fd = env.getIntField(objref, "fd");
        long off = env.getLongField(objref, "off");
        if (content.get(fd) == null) {
            int mode = env.getIntField(objref, "mode");
            int fnRef = env.getReferenceField(objref, "fileName");
            String fname = env.getStringObject(fnRef);
            if (mode == FD_READ) {
                FileInputStream fis = new FileInputStream(fname);
                FileChannel fc = fis.getChannel();
                fc.position(off);
                content.set(fd, fis);
            } else if (mode == FD_WRITE) {
                FileOutputStream fos = new FileOutputStream(fname);
                FileChannel fc = fos.getChannel();
                fc.position(off);
                content.set(fd, fos);
            } else {
                env.throwException("java.io.IOException", "illegal mode: " + mode);
            }
        }
    }
public <E extends Exception> void doWithConnection(String httpAddress, ICallableWithParameter<Void, URLConnection, E> toDo) throws E, ConnectionException {
        URLConnection connection;
        try {
            URL url = new URL(httpAddress);
            connection = url.openConnection();
        } catch (MalformedURLException e) {
            throw new ConnectionException("Connecting to " + httpAddress + " got", e);
        } catch (IOException e) {
            throw new ConnectionException("Connecting to " + httpAddress + " got", e);
        }
        authenticationHandler.doWithProxyAuthentication(connection, toDo);
    }
public static void main(String[] a) throws Exception {
        HashMap<String, Integer> numberOfOccurencesOfThisComboe = new HashMap<String, Integer>();
        HashMap<String, String> fileToCATHMapping = new HashMap<String, String>();
        ArrayList<String> allFilesToBeCopied = new ArrayList<String>();
        new File(outputDir).mkdirs();
        FileReader fis = new FileReader(completeFileWithDirToCathFileList);
        BufferedReader bis = new BufferedReader(fis);
        String line = "";
        String currentCombo = "";
        while ((line = bis.readLine()) != null) {
            String[] allEntries = line.split("\\s+");
            String fileName = allEntries[0];
            String thisCombo = allEntries[1] + allEntries[2] + allEntries[3] + allEntries[4];
            String reducedComboForFilteringOut = allEntries[1] + allEntries[2] + allEntries[3];
            fileToCATHMapping.put(fileName, reducedComboForFilteringOut);
            if (currentCombo.equals(thisCombo)) {
            } else {
                System.out.println("merke: " + fileName);
                allFilesToBeCopied.add(fileName);
                currentCombo = thisCombo;
            }
        }
        for (String fileName : allFilesToBeCopied) {
            String reducedComboForFilteringOut = fileToCATHMapping.get(fileName);
            if (!numberOfOccurencesOfThisComboe.containsKey(reducedComboForFilteringOut)) {
                numberOfOccurencesOfThisComboe.put(reducedComboForFilteringOut, 1);
            } else {
                Integer thisCounter = numberOfOccurencesOfThisComboe.get(reducedComboForFilteringOut);
                thisCounter = thisCounter + 1;
                numberOfOccurencesOfThisComboe.put(reducedComboForFilteringOut, thisCounter);
            }
        }
        HashSet<String> isSingleElement = new HashSet<String>();
        for (Entry<String, Integer> thisEntry : numberOfOccurencesOfThisComboe.entrySet()) {
            if (thisEntry.getValue() == 1) {
                System.out.println("single: " + thisEntry.getKey());
                isSingleElement.add(thisEntry.getKey());
            } else {
                System.out.println("not single: " + thisEntry.getKey());
            }
        }
        System.out.println(allFilesToBeCopied.size());
        for (String file : allFilesToBeCopied) {
            if (!isSingleElement.contains(fileToCATHMapping.get(file))) {
                try {
                    FileChannel srcChannel = new FileInputStream(CathDir + file).getChannel();
                    FileChannel dstChannel = new FileOutputStream(outputDir + file).getChannel();
                    dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
                    srcChannel.close();
                    dstChannel.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
public void updateMetaList() {
        metaserverModel.begin();
        serverCache.expire(EXPIRE_INTERVAL * 1000);
        final Map<String, MetaserverEntry> oldEntries = serverCache.getAll();
        final MetaserverEntry localhostMetaserverEntry = MetaserverEntryParser.parseEntry(ServerCache.DEFAULT_ENTRY_LOCALHOST);
        assert localhostMetaserverEntry != null;
        metaserverModel.add(localhostMetaserverEntry);
        oldEntries.remove(ServerCache.makeKey(localhostMetaserverEntry));
        serverCache.put(localhostMetaserverEntry);
        try {
            final URL url = new URL(METASERVER_URL);
            final String httpProxy = System.getenv("http_proxy");
            if (httpProxy != null && httpProxy.length() > 0) {
                if (httpProxy.regionMatches(true, 0, "http://", 0, 7)) {
                    final String[] tmp = httpProxy.substring(7).replaceAll("/.*", "").split(":", 2);
                    System.setProperty("http.proxyHost", tmp[0]);
                    System.setProperty("http.proxyPort", tmp.length >= 2 ? tmp[1] : "80");
                } else {
                    System.err.println("Warning: unsupported http_proxy protocol: " + httpProxy);
                }
            }
            final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            try {
                conn.setRequestMethod("GET");
                conn.setUseCaches(false);
                conn.connect();
                if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
                    final InputStream in = conn.getInputStream();
                    final InputStreamReader isr = new InputStreamReader(in, "ISO-8859-1");
                    try {
                        final BufferedReader br = new BufferedReader(isr);
                        try {
                            final MetaserverEntryParser metaserverEntryParser = new MetaserverEntryParser();
                            while (true) {
                                final String line = br.readLine();
                                if (line == null) {
                                    break;
                                }
                                final MetaserverEntry metaserverEntry = metaserverEntryParser.parseLine(line);
                                if (metaserverEntry != null) {
                                    metaserverModel.add(metaserverEntry);
                                    oldEntries.remove(ServerCache.makeKey(metaserverEntry));
                                    serverCache.put(metaserverEntry);
                                }
                            }
                        } finally {
                            br.close();
                        }
                    } finally {
                        isr.close();
                    }
                }
            } finally {
                conn.disconnect();
            }
        } catch (final IOException ignored) {
        }
        for (final MetaserverEntry metaserverEntry : oldEntries.values()) {
            metaserverModel.add(metaserverEntry);
        }
        metaserverModel.commit();
        serverCache.save();
    }
public static final void sequence(int[] list, int above) {
        int temp, max, min;
        boolean tag = true;
        for (int i = list.length - 1; i >= 0; i--) {
            for (int j = 0; j < i; j++) {
                if (above < 0) {
                    if (list[j] < list[j + 1]) {
                        temp = list[j];
                        list[j] = list[j + 1];
                        list[j + 1] = temp;
                        tag = true;
                    }
                } else {
                    if (list[j] > list[j + 1]) {
                        temp = list[j];
                        list[j] = list[j + 1];
                        list[j + 1] = temp;
                        tag = true;
                    }
                }
            }
            if (tag == false) break;
        }
    }
public static void bubbleSort(int[] polje) {
        boolean swapped;
        int temp;
        int n = polje.length;
        do {
            swapped = false;
            n--;
            for (int i = 0; i < n - 1; i++) {
                if (polje[i] > polje[i + 1]) {
                    temp = polje[i];
                    polje[i] = polje[i + 1];
                    polje[i + 1] = temp;
                    swapped = true;
                }
            }
        } while (swapped);
    }
public boolean download(String address, String localFileName) {
        OutputStream out = null;
        URLConnection conn = null;
        InputStream in = null;
        try {
            URL url = new URL(address);
            out = new BufferedOutputStream(new FileOutputStream(localFileName));
            conn = url.openConnection();
            in = conn.getInputStream();
            byte[] buffer = new byte[1024];
            int numRead;
            long numWritten = 0;
            while ((numRead = in.read(buffer)) != -1) {
                out.write(buffer, 0, numRead);
                numWritten += numRead;
            }
            return true;
        } catch (Exception exception) {
            exception.printStackTrace();
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
                if (out != null) {
                    out.close();
                }
            } catch (IOException ioe) {
            }
        }
        return false;
    }
public InputStream getResource(String resourceName) throws IOException {
        if (!resourceName.startsWith("/")) {
            resourceName += "/";
        }
        URL url = bc.getBundle().getResource(COOS_CONFIG_PATH + resourceName);
        InputStream is = null;
        try {
            FileInputStream fis = new FileInputStream(configDir + resourceName);
            is = substitute(fis);
        } catch (Exception e) {
        }
        if (is == null) {
            is = url.openStream();
            is = substitute(is);
        }
        return is;
    }
public void ztest_cluster() throws Exception {
        Configuration.init();
        TomcatServer ts1 = new TomcatServer();
        ts1.registerServlet("/*", TestServlet.class.getName());
        ts1.registerCluster(5554);
        ts1.start(5555);
        TomcatServer ts2 = new TomcatServer();
        ts2.registerServlet("/*", TestServlet.class.getName());
        ts2.registerCluster(5554);
        ts2.start(5556);
        URL url1 = new URL("http://127.0.0.1:5555/a");
        HttpURLConnection c1 = (HttpURLConnection) url1.openConnection();
        assert getData(c1).equals("a null");
        String cookie = c1.getHeaderField("Set-Cookie");
        Thread.sleep(5000);
        URL url2 = new URL("http://127.0.0.1:5556/a");
        HttpURLConnection c2 = (HttpURLConnection) url2.openConnection();
        c2.setRequestProperty("Cookie", cookie);
        assert getData(c2).equals("a a");
    }
public void test_filecluster() throws Exception {
        Configuration.init();
        LruPersistentManager sessionManager2 = new LruPersistentManager(new File("d:/temp/test"));
        TomcatServer ts2 = new TomcatServer("hf1", sessionManager2);
        ts2.registerServlet("/*", TestServlet.class.getName());
        ts2.start(5556);
        LruPersistentManager sessionManager1 = new LruPersistentManager(new File("d:/temp/test"));
        TomcatServer ts1 = new TomcatServer("hf2", sessionManager1);
        ts1.registerServlet("/*", TestServlet.class.getName());
        ts1.start(5555);
        URL url1 = new URL("http://127.0.0.1:5555/a");
        HttpURLConnection c1 = (HttpURLConnection) url1.openConnection();
        assert getData(c1).equals("a null");
        String cookie = c1.getHeaderField("Set-Cookie");
        Thread.sleep(10000);
        URL url2 = new URL("http://127.0.0.1:5556/a");
        HttpURLConnection c2 = (HttpURLConnection) url2.openConnection();
        c2.setRequestProperty("Cookie", cookie);
        assert getData(c2).equals("a a");
        Thread.sleep(15000);
    }