semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public void issue(String licenseId, Map answers, String lang) throws IOException {
        String issueUrl = this.rest_root + "/license/" + licenseId + "/issue";
        String answer_doc = "<answers>\n<license-" + licenseId + ">";
        Iterator keys = answers.keySet().iterator();
        try {
            String current = (String) keys.next();
            while (true) {
                answer_doc += "<" + current + ">" + (String) answers.get(current) + "</" + current + ">\n";
                current = (String) keys.next();
            }
        } catch (NoSuchElementException e) {
        }
        answer_doc += "</license-" + licenseId + ">\n</answers>\n";
        String post_data;
        try {
            post_data = URLEncoder.encode("answers", "UTF-8") + "=" + URLEncoder.encode(answer_doc, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            return;
        }
        URL post_url;
        try {
            post_url = new URL(issueUrl);
        } catch (MalformedURLException e) {
            return;
        }
        URLConnection conn = post_url.openConnection();
        conn.setDoOutput(true);
        OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
        wr.write(post_data);
        wr.flush();
        try {
            this.license_doc = this.parser.build(conn.getInputStream());
        } catch (JDOMException e) {
            System.out.print("Danger Will Robinson, Danger!");
        }
        return;
    }
public static String SHA1(String text, int HASH_VALUE_SIZE) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        MessageDigest md;
        md = MessageDigest.getInstance("SHA-1");
        byte[] sha1hash = new byte[HASH_VALUE_SIZE];
        md.update(text.getBytes("iso-8859-1"), 0, text.length());
        sha1hash = md.digest();
        return convertToHex(sha1hash);
    }
public static byte[] SHA1byte(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        MessageDigest md;
        md = MessageDigest.getInstance("SHA-1");
        byte[] sha1hash = new byte[40];
        md.update(text.getBytes("iso-8859-1"), 0, text.length());
        sha1hash = md.digest();
        return sha1hash;
    }
public ScriptInfoList getScriptList() {
        ScriptInfoList scripts = null;
        try {
            URL url = new URL(SCRIPT_URL + "?customer=" + customerID);
            ObjectInputStream ois = new ObjectInputStream(url.openStream());
            scripts = (ScriptInfoList) ois.readObject();
            ois.close();
            System.out.println("got script list");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return scripts;
    }
public MeetingScript getScript(Integer id) {
        MeetingScript script = null;
        try {
            URL url = new URL(SCRIPT_URL + "?script=" + id);
            ObjectInputStream ois = new ObjectInputStream(url.openStream());
            script = (MeetingScript) ois.readObject();
            ois.close();
            System.out.println("got script");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return script;
    }
private void postObject(Object obj, String strURL) throws Exception {
        print("entering post object");
        URL url = new URL(strURL);
        URLConnection urlConn = url.openConnection();
        print("HttpNetworkMessageConnection.postObject:returned from url.openConnection()");
        urlConn.setUseCaches(false);
        urlConn.setDoOutput(true);
        ObjectOutputStream oos = new ObjectOutputStream(urlConn.getOutputStream());
        print("HttpNetworkMessageConnection.postObject:returned from urlConn.getOutputStream()");
        oos.writeObject(obj);
        print("HttpNetworkMessageConnection.postObject:returned from writeObject()");
        oos.flush();
        oos.close();
        InputStream is = urlConn.getInputStream();
        print("HttpNetworkMessageConnection.postObject:returned from getInputStream()");
        while (is.read() != -1) {
        }
        is.close();
        print("exiting postObject");
    }
public static void upper() throws Exception {
        TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() {

            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
                return null;
            }

            public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType) {
            }

            public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
            }
        } };
        SSLContext sc = SSLContext.getInstance("SSL");
        sc.init(null, trustAllCerts, new java.security.SecureRandom());
        HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
        HostnameVerifier hv = new HostnameVerifier() {

            public boolean verify(String urlHostName, SSLSession session) {
                System.out.println("Warning: URL Host: " + urlHostName + " vs. " + session.getPeerHost());
                return true;
            }
        };
        HttpsURLConnection.setDefaultHostnameVerifier(hv);
        URL url = new URL("https://test.ctpe.net/payment/query");
        URLConnection conn = url.openConnection();
        String data = "<Request version='1.0'> " + "<Header>  " + "  <Security sender='ff80808109c5bcc00109c5bce9f1003a'/>  " + "</Header>  " + "<Query entity='ff80808109c5bcc00109c5bce9f50056' level='CHANNEL' mode='INTEGRATOR_TEST'> " + "  <User login='ff80808109c5bcc00109c5bce9f20042' pwd='geheim'/>  " + "  <Period from='2006-03-04' to='2006-03-04'/>  " + "  <Types>  " + "    <Type code='RF'/> " + "    <Type code='PA'/>  " + "    <Type code='RV'/>  " + "  </Types>  " + "</Query>  " + "</Request>  ";
        conn.setDoOutput(true);
        OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
        wr.write("load=" + data);
        wr.flush();
        wr.close();
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        String line;
        while ((line = rd.readLine()) != null) {
            System.out.println(line);
        }
        rd.close();
    }
public static String getHash(String text) {
        String ret = null;
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-256");
            md.update(text.getBytes());
            ret = getHex(md.digest());
        } catch (NoSuchAlgorithmException e) {
            log.error(e);
            throw new OopsException(e, "Hash Error.");
        }
        return ret;
    }
public static void load(String path) {
        if (path.length() < 1) {
            Log.userinfo("Cannot open a file whose name has zero length.", Log.ERROR);
        }
        if (!loadtime) {
            if (path.equals(Globals.getStartupFilePath())) {
                Log.userinfo("Cannot reload startup file.", Log.ERROR);
            }
        }
        BufferedReader buffReader = null;
        if (path.indexOf("://") != -1) {
            URL url = null;
            try {
                url = new URL(path);
            } catch (MalformedURLException e) {
                Log.userinfo("Malformed URL: \"" + path + "\"", Log.ERROR);
            }
            try {
                String encoding = Toolkit.getDeclaredXMLEncoding(url.openStream());
                buffReader = new BufferedReader(new InputStreamReader(url.openStream(), encoding));
            } catch (IOException e) {
                Log.userinfo("I/O error trying to read \"" + path + "\"", Log.ERROR);
            }
        } else {
            if (path.indexOf(ASTERISK) != -1) {
                String[] files = null;
                try {
                    files = Toolkit.glob(path, workingDirectory);
                } catch (FileNotFoundException e) {
                    Log.userinfo(e.getMessage(), Log.ERROR);
                }
                if (files != null) {
                    for (int index = 0; index < files.length; index++) {
                        load(files[index]);
                    }
                    return;
                }
            }
            File toRead = new File(path);
            if (toRead.isAbsolute()) {
                workingDirectory = toRead.getParent();
            }
            if (loadedFiles.contains(toRead)) {
                if (loadtime) {
                    return;
                }
            } else {
                loadedFiles.add(toRead);
            }
            if (toRead.exists() && !toRead.isDirectory()) {
                try {
                    String encoding = Toolkit.getDeclaredXMLEncoding(new FileInputStream(path));
                    buffReader = new BufferedReader(new InputStreamReader(new FileInputStream(path), encoding));
                } catch (IOException e) {
                    Log.userinfo("I/O error trying to read \"" + path + "\"", Log.ERROR);
                    return;
                }
                if (Globals.isWatcherActive()) {
                    AIMLWatcher.addWatchFile(path);
                }
            } else {
                if (!toRead.exists()) {
                    Log.userinfo("\"" + path + "\" does not exist!", Log.ERROR);
                }
                if (toRead.isDirectory()) {
                    Log.userinfo("\"" + path + "\" is a directory!", Log.ERROR);
                }
            }
        }
        new AIMLReader(path, buffReader, new AIMLLoader(path)).read();
    }
private GenomicSequence fetch(Chromosome k, int start, int end) throws IOException {
        try {
            String chr = k.toString();
            if (chr.toLowerCase().startsWith("chr")) chr = chr.substring(3);
            SAXParserFactory f = SAXParserFactory.newInstance();
            f.setNamespaceAware(false);
            f.setValidating(false);
            SAXParser parser = f.newSAXParser();
            URL url = new URL("http://genome.ucsc.edu/cgi-bin/das/" + genomeVersion + "/dna?segment=" + URLEncoder.encode(chr, "UTF-8") + ":" + (start + 1) + "," + (end));
            DASHandler handler = new DASHandler();
            InputStream in = url.openStream();
            parser.parse(in, handler);
            in.close();
            GenomicSequence seq = new GenomicSequence();
            seq.sequence = handler.bytes.toByteArray();
            seq.start = start;
            seq.end = end;
            if (seq.sequence.length != seq.length()) throw new IOException("bad bound " + seq + " " + seq.sequence.length + " " + seq.length());
            return seq;
        } catch (IOException err) {
            throw err;
        } catch (Exception e) {
            throw new IOException(e);
        }
    }
public Document getWsdlDomResource(String aResourceName) throws AeException {
        logger.debug("getWsdlDomResource() " + aResourceName);
        InputStream in = null;
        try {
            URL url = getDeploymentContext().getResourceURL(aResourceName);
            if (url == null) {
                logger.error("url is null");
                return null;
            } else {
                logger.debug("loading wsdl document " + aResourceName);
                in = url.openStream();
                return getSdlParser().loadWsdlDocument(in, null);
            }
        } catch (Throwable t) {
            logger.error("Error: " + t + " for " + aResourceName);
            throw new SdlDeploymentException(MessageFormat.format("unable to load: {0} from {1}", new Object[] { aResourceName, getDeploymentContext().getDeploymentLocation() }), t);
        } finally {
            AeCloser.close(in);
        }
    }
@Override
        public void respondGet(HttpServletResponse resp) throws IOException {
            setHeaders(resp);
            final OutputStream os;
            if (willDeflate()) {
                resp.setHeader("Content-Encoding", "gzip");
                os = new GZIPOutputStream(resp.getOutputStream(), bufferSize);
            } else os = resp.getOutputStream();
            transferStreams(url.openStream(), os);
        }
private static void checkClients() {
        try {
            sendMultiListEntry('l');
        } catch (Exception e) {
            if (Util.getDebugLevel() > 90) e.printStackTrace();
        }
        try {
            if (CANT_CHECK_CLIENTS != null) KeyboardHero.removeStatus(CANT_CHECK_CLIENTS);
            URL url = new URL(URL_STR + "?req=clients" + (server != null ? "&port=" + server.getLocalPort() : ""));
            URLConnection connection = url.openConnection(getProxy());
            connection.setRequestProperty("User-Agent", USER_AGENT);
            BufferedReader bufferedRdr = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String ln;
            if (Util.getDebugLevel() > 30) Util.debug("URL: " + url);
            while ((ln = bufferedRdr.readLine()) != null) {
                String[] parts = ln.split(":", 2);
                if (parts.length < 2) {
                    Util.debug(12, "Line read in checkClients: " + ln);
                    continue;
                }
                try {
                    InetSocketAddress address = new InetSocketAddress(parts[0], Integer.parseInt(parts[1]));
                    boolean notFound = true;
                    if (Util.getDebugLevel() > 25) Util.debug("NEW Address: " + address.toString());
                    synchronized (clients) {
                        Iterator<Client> iterator = clients.iterator();
                        while (iterator.hasNext()) {
                            final Client client = iterator.next();
                            if (client.socket.isClosed()) {
                                iterator.remove();
                                continue;
                            }
                            if (Util.getDebugLevel() > 26 && client.address != null) Util.debug("Address: " + client.address.toString());
                            if (address.equals(client.address)) {
                                notFound = false;
                                break;
                            }
                        }
                    }
                    if (notFound) {
                        connectClient(address);
                    }
                } catch (NumberFormatException e) {
                }
            }
            bufferedRdr.close();
        } catch (MalformedURLException e) {
            Util.conditionalError(PORT_IN_USE, "Err_PortInUse");
            Util.error(Util.getMsg("Err_CantCheckClients"));
        } catch (FileNotFoundException e) {
            Util.error(Util.getMsg("Err_CantCheckClients_Proxy"), Util.getMsg("Err_FileNotFound"));
        } catch (SocketException e) {
            Util.error(Util.getMsg("Err_CantCheckClients_Proxy"), e.getLocalizedMessage());
        } catch (Exception e) {
            CANT_CHECK_CLIENTS.setException(e.toString());
            KeyboardHero.addStatus(CANT_CHECK_CLIENTS);
        }
    }
public void run() {
                try {
                    URL url = new URL(URL_STR + "?req=list");
                    URLConnection connection = url.openConnection(getProxy());
                    connection.setRequestProperty("User-Agent", USER_AGENT);
                    BufferedReader bufferedRdr = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                    String line = null;
                    int foundCount = 0;
                    ArrayList<String> names = new ArrayList<String>();
                    ArrayList<String> songs = new ArrayList<String>();
                    ArrayList<Integer> scores = new ArrayList<Integer>();
                    ArrayList<Float> factors = new ArrayList<Float>();
                    String[] subparts;
                    String[] ssubparts;
                    int tlscore;
                    float tlfactor;
                    while ((line = bufferedRdr.readLine()) != null) {
                        if (line.length() > 2) {
                            try {
                                subparts = line.split(" ", 3);
                                if (subparts.length != 3) {
                                    Util.debug(28, "Not enough subentry in online toplist file: ." + KeyboardHero.APP_NAME + ".tls!");
                                    continue;
                                }
                                tlscore = Integer.parseInt(subparts[1]);
                                tlfactor = Float.parseFloat(subparts[0]);
                                scores.add(tlscore);
                                factors.add(tlfactor);
                                ssubparts = hexdecode(subparts[2]).split("¦", 2);
                                if (ssubparts.length != 2) {
                                    Util.debug(26, "Not enough subsubentry in online toplist file: ." + KeyboardHero.APP_NAME + ".tls!");
                                    continue;
                                }
                                songs.add(ssubparts[0]);
                                names.add(ssubparts[1]);
                                foundCount++;
                            } catch (NumberFormatException e) {
                                Util.debug(24, "Corrupted toplist score and/or level number in the online toplist!");
                            } catch (ArrayIndexOutOfBoundsException e) {
                                Util.debug(25, "Corrupted toplist entry in the online toplist!");
                            }
                        }
                    }
                    bufferedRdr.close();
                    ((DialogToplist) KeyboardHero.getDialogs().get("toplist")).setContent(names.toArray(new String[0]), scores.toArray(new Integer[0]), songs.toArray(new String[0]), factors.toArray(new Float[0]), foundCount, -1);
                } catch (Exception e) {
                    ((DialogToplist) KeyboardHero.getDialogs().get("toplist")).setStatusText(Util.getMsg("CannotToplist") + "!\n\n" + e.toString(), false);
                }
            }
public static Element postMessage() throws Exception {
        final URL theUrl = getHostURL();
        lf.debug("url = " + theUrl.toExternalForm());
        final HttpURLConnection urlConn = (HttpURLConnection) (theUrl).openConnection();
        urlConn.setRequestMethod("POST");
        urlConn.setDoInput(true);
        urlConn.setDoOutput(true);
        final BufferedOutputStream bos = new BufferedOutputStream(urlConn.getOutputStream());
        final InputStream bis = urlConn.getInputStream();
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final byte[] buffer = new byte[1024];
        int count = 0;
        while ((count = bis.read(buffer)) > -1) {
            baos.write(buffer, 0, count);
        }
        final SAXBuilder sb = new SAXBuilder();
        lf.debug("Received XML response from server: " + baos.toString());
        return sb.build(new StringReader(baos.toString())).getRootElement();
    }
public static void main(String[] args) throws IOException {
        System.setProperty("java.protocol.xfile", "com.luzan.common.nfs");
        if (args.length < 1) usage();
        final String cmd = args[0];
        if ("delete".equalsIgnoreCase(cmd)) {
            final String path = getParameter(args, 1);
            XFile xfile = new XFile(path);
            if (!xfile.exists()) {
                System.out.print("File doean't exist.\n");
                System.exit(1);
            }
            xfile.delete();
        } else if ("copy".equalsIgnoreCase(cmd)) {
            final String pathFrom = getParameter(args, 1);
            final String pathTo = getParameter(args, 2);
            final XFile xfileFrom = new XFile(pathFrom);
            final XFile xfileTo = new XFile(pathTo);
            if (!xfileFrom.exists()) {
                System.out.print("File doesn't exist.\n");
                System.exit(1);
            }
            final String mime = getParameter(args, 3, null);
            final XFileInputStream in = new XFileInputStream(xfileFrom);
            final XFileOutputStream xout = new XFileOutputStream(xfileTo);
            if (!StringUtils.isEmpty(mime)) {
                final com.luzan.common.nfs.s3.XFileExtensionAccessor xfa = ((com.luzan.common.nfs.s3.XFileExtensionAccessor) xfileTo.getExtensionAccessor());
                if (xfa != null) {
                    xfa.setMimeType(mime);
                    xfa.setContentLength(xfileFrom.length());
                }
            }
            IOUtils.copy(in, xout);
            xout.flush();
            xout.close();
            in.close();
        }
    }
private static long writeVMDKFile(String absoluteFile, String urlString) throws Exception {
        URL urlCon = new URL(urlString);
        HttpsURLConnection conn = (HttpsURLConnection) urlCon.openConnection();
        conn.setDoInput(true);
        conn.setDoOutput(true);
        conn.setAllowUserInteraction(true);
        List cookies = (List) headers.get("Set-cookie");
        cookieValue = (String) cookies.get(0);
        StringTokenizer tokenizer = new StringTokenizer(cookieValue, ";");
        cookieValue = tokenizer.nextToken();
        String path = "$" + tokenizer.nextToken();
        String cookie = "$Version=\"1\"; " + cookieValue + "; " + path;
        Map map = new HashMap();
        map.put("Cookie", Collections.singletonList(cookie));
        ((BindingProvider) vimPort).getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, map);
        conn.setRequestProperty("Cookie", cookie);
        conn.setRequestProperty("Content-Type", "application/octet-stream");
        conn.setRequestProperty("Expect", "100-continue");
        conn.setRequestMethod("GET");
        conn.setRequestProperty("Content-Length", "1024");
        InputStream in = conn.getInputStream();
        String localpath = localPath + "/" + absoluteFile;
        OutputStream out = new FileOutputStream(new File(localpath));
        byte[] buf = new byte[102400];
        int len = 0;
        long written = 0;
        while ((len = in.read(buf)) > 0) {
            out.write(buf, 0, len);
            written = written + len;
        }
        System.out.println("   Exported File " + absoluteFile + " : " + written);
        in.close();
        out.close();
        return written;
    }
private String generaHashMD5(String plainText) throws Exception {
        MessageDigest mdAlgorithm = MessageDigest.getInstance("MD5");
        mdAlgorithm.update(plainText.getBytes(FirmaUtil.CHARSET));
        byte[] digest = mdAlgorithm.digest();
        return toHex(digest);
    }
public static InputStream getInputStream(URL url) throws IOException {
        if (url.getProtocol().equals("file")) {
            String path = decode(url.getPath(), "UTF-8");
            return new BufferedInputStream(new FileInputStream(path));
        } else {
            return new BufferedInputStream(url.openStream());
        }
    }