semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
String getLatestVersion() {
        try {
            URL url = new URL(Constants.VERSION_FILE_URL);
            URLConnection connection = url.openConnection();
            connection.setConnectTimeout(15000);
            InputStream in = connection.getInputStream();
            BufferedReader br = new BufferedReader(new InputStreamReader(in));
            return br.readLine();
        } catch (Exception ex) {
            return null;
        }
    }
public void connectToUrl(String url_address) {
        message = new StringBuffer("");
        try {
            URL url = new URL(url_address);
            try {
                HttpsURLConnection httpsConnection = (HttpsURLConnection) url.openConnection();
                httpsConnection.setDoOutput(false);
                httpsConnection.connect();
                message.append("<BR>\n Connection Code:[" + httpsConnection.getResponseCode() + "]");
                message.append("<BR>\n Response Message:[" + httpsConnection.getResponseMessage() + "]");
                InputStreamReader insr = new InputStreamReader(httpsConnection.getInputStream());
                BufferedReader in = new BufferedReader(insr);
                fullStringBuffer = new StringBuffer("");
                String temp = in.readLine();
                while (temp != null) {
                    fullStringBuffer.append(temp);
                    temp = in.readLine();
                }
                in.close();
            } catch (IOException e) {
                message.append("<BR>\n [Error][IOException][" + e.getMessage() + "]");
            }
        } catch (MalformedURLException e) {
            message.append("<BR>\n [Error][MalformedURLException][" + e.getMessage() + "]");
        } catch (Exception e) {
            message.append("<BR>\n [Error][Exception][" + e.getMessage() + "]");
        }
    }
public boolean refresh() {
        try {
            synchronized (text) {
                stream = (new URL(url)).openStream();
                BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
                String line;
                StringBuilder sb = new StringBuilder();
                while ((line = reader.readLine()) != null) {
                    sb.append(line);
                    sb.append("\n");
                }
                text = sb.toString();
            }
            price = 0;
            date = null;
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
            return false;
        } finally {
            if (stream != null) try {
                stream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return true;
    }
@Override
        protected DefaultHttpClient doInBackground(Account... params) {
            AccountManager accountManager = AccountManager.get(mainActivity);
            Account account = params[0];
            try {
                Bundle bundle = accountManager.getAuthToken(account, "ah", false, null, null).getResult();
                Intent intent = (Intent) bundle.get(AccountManager.KEY_INTENT);
                if (intent != null) {
                    mainActivity.startActivity(intent);
                } else {
                    String auth_token = bundle.getString(AccountManager.KEY_AUTHTOKEN);
                    http_client.getParams().setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, false);
                    HttpGet http_get = new HttpGet("http://3dforandroid.appspot.com/_ah" + "/login?continue=http://localhost/&auth=" + auth_token);
                    HttpResponse response = http_client.execute(http_get);
                    if (response.getStatusLine().getStatusCode() != 302) return null;
                    for (Cookie cookie : http_client.getCookieStore().getCookies()) {
                        if (cookie.getName().equals("ACSID")) {
                            authClient = http_client;
                            String json = createJsonFile(Kind);
                            initializeSQLite();
                            initializeServer(json);
                        }
                    }
                }
            } catch (OperationCanceledException e) {
                e.printStackTrace();
            } catch (AuthenticatorException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return http_client;
        }
protected List<String[]> execute(String queryString, String sVar1, String sVar2, String filter) throws Exception {
        String query = URLEncoder.encode(queryString, "UTF-8");
        String urlString = "http://sparql.bibleontology.com/sparql.jsp?sparql=" + query + "&type1=xml";
        URL url;
        BufferedReader br = null;
        ArrayList<String[]> values = new ArrayList<String[]>();
        try {
            url = new URL(urlString);
            URLConnection conn = url.openConnection();
            br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            StringBuffer sb = new StringBuffer();
            String line;
            String sURI1 = null;
            String sURI2 = null;
            boolean b1 = false;
            boolean b2 = false;
            while ((line = br.readLine()) != null) {
                if (line.indexOf("</result>") != -1) {
                    if (sURI1 != null && sURI2 != null) {
                        String pair[] = { sURI1, sURI2 };
                        values.add(pair);
                    }
                    sURI1 = null;
                    sURI2 = null;
                    b1 = false;
                    b2 = false;
                }
                if (line.indexOf("binding name=\"" + sVar1 + "\"") != -1) {
                    b1 = true;
                    continue;
                } else if (b1) {
                    String s1 = getURI(line);
                    if (s1 != null) {
                        s1 = checkURISyntax(s1);
                        if (filter == null || s1.startsWith(filter)) {
                            sURI1 = s1;
                        }
                    }
                    b1 = false;
                    continue;
                }
                if (line.indexOf("binding name=\"" + sVar2 + "\"") != -1) {
                    b2 = true;
                    continue;
                } else if (b2) {
                    String s2 = getURI(line);
                    if (s2 != null) {
                        s2 = checkURISyntax(s2);
                        if (filter == null || s2.startsWith(filter)) {
                            sURI2 = s2;
                        }
                    }
                    b2 = false;
                    continue;
                }
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            br.close();
        }
        return values;
    }
protected List<String> execute(String queryString, String sVar, String filter) throws UnsupportedEncodingException, IOException {
        String query = URLEncoder.encode(queryString, "UTF-8");
        String urlString = "http://sparql.bibleontology.com/sparql.jsp?sparql=" + query + "&type1=xml";
        URL url;
        BufferedReader br = null;
        ArrayList<String> values = new ArrayList<String>();
        try {
            url = new URL(urlString);
            URLConnection conn = url.openConnection();
            br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            StringBuffer sb = new StringBuffer();
            String line;
            while ((line = br.readLine()) != null) {
                String sURI = getURI(line);
                if (sURI != null) {
                    sURI = checkURISyntax(sURI);
                    if (filter == null || sURI.startsWith(filter)) {
                        values.add(sURI);
                    }
                }
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            br.close();
        }
        return values;
    }
public void sendMessage(Message msg) {
        if (!blackList.contains(msg.getTo())) {
            Hashtable<String, String> content = msg.getContent();
            Enumeration<String> keys = content.keys();
            String key;
            String data = "to=" + msg.getTo() + "&from=" + msg.getFrom() + "&";
            while (keys.hasMoreElements()) {
                key = (String) keys.nextElement();
                data += key + "=" + content.get(key) + "&";
            }
            URL url = null;
            try {
                logger.log(this, Level.FINER, "sending " + data + " to " + msg.getTo());
                url = new URL("http://" + msg.getTo() + ":8080/webmsgservice?" + data);
                BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                in.readLine();
                in.close();
                logger.log(this, Level.FINER, "message sent to " + msg.getTo());
            } catch (MalformedURLException e) {
                blackList.add(msg.getTo());
                logger.log(this, Level.WARNING, "an error occured during message sending (" + msg.getTo() + ") : " + e.getMessage());
                e.printStackTrace();
            } catch (IOException e) {
                logger.log(this, Level.WARNING, "an error occured during message sending (" + msg.getTo() + ") : " + e.getMessage());
                blackList.add(msg.getTo());
            }
        } else {
            logger.log(this, Level.FINE, "will not send message to " + msg.getTo() + " because black listed IP");
        }
    }
public XMLResourceBundle() throws MissingResourceException {
        String systemId = getShortName() + ".xml";
        URL url;
        if ((url = getClass().getResource(systemId)) != null) {
            InputStream is = null;
            try {
                is = url.openStream();
                SAXParserFactory factory = SAXParserFactory.newInstance();
                factory.setNamespaceAware(false);
                factory.setValidating(false);
                XMLReader xmlReader = factory.newSAXParser().getXMLReader();
                xmlReader.setContentHandler(new MessageContentHandler());
                xmlReader.parse(new InputSource(is));
            } catch (IOException ioe) {
                System.err.println(ioe.getMessage());
                ioe.printStackTrace();
            } catch (SAXException se) {
                System.err.println(se.getMessage());
                se.printStackTrace();
            } catch (ParserConfigurationException pce) {
                System.err.println(pce.getMessage());
                pce.printStackTrace();
            } finally {
                try {
                    if (is != null) is.close();
                } catch (IOException ioe) {
                    System.err.println(ioe.getMessage());
                    ioe.printStackTrace();
                }
            }
        } else {
            throw new MissingResourceException("Resource file '" + systemId + "' could not be found.", systemId, null);
        }
    }
private File copyFile(String fileInClassPath, String systemPath) throws Exception {
        InputStream is = getClass().getResourceAsStream(fileInClassPath);
        OutputStream os = new FileOutputStream(systemPath);
        IOUtils.copy(is, os);
        is.close();
        os.close();
        return new File(systemPath);
    }
private ProgramYek getYek(String keyFilename) {
        File f = new File(keyFilename);
        InputStream is = null;
        try {
            is = new FileInputStream(f);
        } catch (java.io.FileNotFoundException ee) {
        } catch (Exception e) {
            System.out.println("** Exception reading key: " + e);
        }
        if (is == null) {
            try {
                URL url = ChiselResources.getResourceByName(ProgramYek.getVidSys(), ChiselResources.LOADFROMCLASSPATH);
                if (url == null) {
                } else {
                    is = url.openStream();
                }
            } catch (Exception e) {
                System.out.println("** Exception reading key: " + e);
            }
        }
        ProgramYek y = null;
        if (is != null) {
            try {
                y = ProgramYek.read(is);
            } catch (Exception e) {
                System.out.println("** Exception reading key: " + e);
            }
        } else {
            File chk = new File(checkFilename);
            if (chk.exists()) {
                System.out.println("This is the evaluation version of " + appname);
                y = new ProgramYek(appname, "Evaluation", "", 15);
                ProgramYek.serialize(y, keyFilename);
            }
        }
        return y;
    }
public static String md5Encrypt(String valueToEncrypted) {
        String encryptedValue = "";
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.update(valueToEncrypted.getBytes());
            BigInteger hash = new BigInteger(1, digest.digest());
            encryptedValue = hash.toString(16);
        } catch (NoSuchAlgorithmException nsae) {
            nsae.printStackTrace();
        }
        return encryptedValue;
    }
public Object sendObjectRequestToSpecifiedServer(java.lang.String serverName, java.lang.String servletName, java.lang.Object request) {
        Object reqxml = null;
        org.jdom.Document retdoc = null;
        String myurl = java.util.prefs.Preferences.systemRoot().get("serverurl", "");
        String myport = java.util.prefs.Preferences.systemRoot().get("portno", "8080");
        if (myport == null || myport.trim().equals("")) {
            myport = "80";
        }
        if (this.serverURL == null) {
            try {
                java.net.URL codebase = newgen.presentation.NewGenMain.getAppletInstance().getCodeBase();
                if (codebase != null) serverURL = codebase.getHost(); else serverURL = "localhost";
            } catch (Exception exp) {
                exp.printStackTrace();
                serverURL = "localhost";
            }
            newgen.presentation.component.IPAddressPortNoDialog ipdig = new newgen.presentation.component.IPAddressPortNoDialog(myurl, myport);
            ipdig.show();
            serverURL = myurl = ipdig.getIPAddress();
            myport = ipdig.getPortNo();
            java.util.prefs.Preferences.systemRoot().put("serverurl", serverURL);
            java.util.prefs.Preferences.systemRoot().put("portno", myport);
            System.out.println(serverURL);
        }
        try {
            java.net.URL url = new java.net.URL("http://" + serverName + ":" + myport + "/newgenlibctxt/" + servletName);
            java.net.URLConnection urlconn = (java.net.URLConnection) url.openConnection();
            urlconn.setDoOutput(true);
            java.io.OutputStream os = urlconn.getOutputStream();
            java.util.zip.CheckedOutputStream cos = new java.util.zip.CheckedOutputStream(os, new java.util.zip.Adler32());
            java.util.zip.GZIPOutputStream gop = new java.util.zip.GZIPOutputStream(cos);
            java.io.ObjectOutputStream dos = new java.io.ObjectOutputStream(gop);
            dos.writeObject(request);
            dos.flush();
            dos.close();
            java.io.InputStream ios = urlconn.getInputStream();
            java.util.zip.CheckedInputStream cis = new java.util.zip.CheckedInputStream(ios, new java.util.zip.Adler32());
            java.util.zip.GZIPInputStream gip = new java.util.zip.GZIPInputStream(cis);
            java.io.ObjectInputStream br = new java.io.ObjectInputStream(gip);
            reqxml = br.readObject();
        } catch (Exception exp) {
            exp.printStackTrace(System.out);
            System.out.println("Exception in Servlet Connector: " + exp);
        }
        return reqxml;
    }
private void loadConfig(ServletContext ctx, String configFileName) {
        Digester digester = new Digester();
        digester.push(this);
        digester.addFactoryCreate("pagespy/server", new AbstractObjectCreationFactory() {

            public Object createObject(Attributes attrs) {
                String className = attrs.getValue("className");
                try {
                    return Class.forName(className).newInstance();
                } catch (Exception e) {
                    throw new ClassCastException("Error al instanciar " + className);
                }
            }
        });
        digester.addSetProperty("pagespy/server/param", "name", "value");
        digester.addSetNext("pagespy/server", "setServer", PageSpyServer.class.getName());
        digester.addCallMethod("pagespy/ignored-patterns", "setIgnorePattern", 1);
        digester.addCallParam("pagespy/ignored-patterns", 0);
        digester.addFactoryCreate("pagespy/property-setters/setter", new AbstractObjectCreationFactory() {

            public Object createObject(Attributes attrs) {
                String className = attrs.getValue("className");
                try {
                    return Class.forName(className).newInstance();
                } catch (Exception e) {
                    throw new ClassCastException("Error al instanciar " + className);
                }
            }
        });
        digester.addSetNext("pagespy/property-setters/setter", "addPropertySetter", PagePropertySetter.class.getName());
        digester.addFactoryCreate("pagespy/page-replacers/replacer", new AbstractObjectCreationFactory() {

            public Object createObject(Attributes attrs) {
                String className = attrs.getValue("className");
                try {
                    return Class.forName(className).newInstance();
                } catch (Exception e) {
                    throw new ClassCastException("Error al instanciar " + className);
                }
            }
        });
        digester.addSetNext("pagespy/page-replacers/replacer", "addPageReplacer", PageReplacer.class.getName());
        digester.addFactoryCreate("pagespy/properties-panel", new AbstractObjectCreationFactory() {

            public Object createObject(Attributes attrs) {
                String className = attrs.getValue("className");
                try {
                    return Class.forName(className).newInstance();
                } catch (Exception e) {
                    throw new ClassCastException("Error al instanciar " + className);
                }
            }
        });
        digester.addSetNext("pagespy/properties-panel", "setPropertiesPanel", PagePanel.class.getName());
        try {
            this.getLogger().info("Initializing " + configFileName);
            URL url = ctx.getResource(configFileName);
            if (url == null) {
                url = this.getClass().getResource(configFileName);
            }
            digester.parse(url.openStream());
        } catch (Exception e) {
            this.getLogger().error("Error parsing configuration file.", e);
            throw new RuntimeException(e);
        }
    }
public static final String encryptMD5(String decrypted) {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(decrypted.getBytes());
            byte hash[] = md5.digest();
            md5.reset();
            return hashToHex(hash);
        } catch (NoSuchAlgorithmException _ex) {
            return null;
        }
    }
public static void copyFile(File source, File dest) {
        try {
            FileChannel in = new FileInputStream(source).getChannel();
            if (!dest.getParentFile().exists()) dest.getParentFile().mkdirs();
            FileChannel out = new FileOutputStream(dest).getChannel();
            in.transferTo(0, in.size(), out);
            in.close();
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
private void fileUpload() throws Exception {
        NULogger.getLogger().info("now file upload code");
        DefaultHttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("https://dl-web.dropbox.com/upload");
        httppost.setHeader("Referer", "https://www.dropbox.com/home/Public");
        httppost.setHeader("Cookie", DropBoxAccount.getForumjarcookie() + ";" + DropBoxAccount.getForumlidcookie() + ";" + DropBoxAccount.getTouchcookie());
        MultipartEntity mpEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
        mpEntity.addPart("t", new StringBody(token));
        mpEntity.addPart("plain", new StringBody("yes"));
        mpEntity.addPart("dest", new StringBody("/Public"));
        mpEntity.addPart("file", new MonitoredFileBody(file, uploadProgress));
        httppost.setEntity(mpEntity);
        NULogger.getLogger().log(Level.INFO, "executing request {0}", httppost.getRequestLine());
        NULogger.getLogger().info("Now uploading your file into dropbox.com");
        status = UploadStatus.UPLOADING;
        HttpResponse response = httpclient.execute(httppost);
        status = UploadStatus.GETTINGLINK;
        HttpEntity resEntity = response.getEntity();
        NULogger.getLogger().info(response.getStatusLine().toString());
        if (resEntity != null) {
            uploadresponse = EntityUtils.toString(resEntity);
        }
        NULogger.getLogger().log(Level.INFO, "Upload response : {0}", uploadresponse);
        if (uploadresponse.contains("The resource was found at https://www.dropbox.com/home/Public")) {
            downloadlink = "http://dl.dropbox.com/u/" + uid + "/" + (URLEncoder.encode(file.getName(), "UTF-8").replace("+", "%20"));
            NULogger.getLogger().log(Level.INFO, "Downloadlink : {0}", downloadlink);
            downURL = downloadlink;
        } else {
            throw new Exception("Dropbox server problem or network problem.. Couldn't get proper response.");
        }
    }
public static void generate(final InputStream input, String format, Point dimension, IPath outputLocation) throws CoreException {
        MultiStatus status = new MultiStatus(GraphVizActivator.ID, 0, "Errors occurred while running Graphviz", null);
        File dotInput = null, dotOutput = outputLocation.toFile();
        ByteArrayOutputStream dotContents = new ByteArrayOutputStream();
        try {
            dotInput = File.createTempFile(TMP_FILE_PREFIX, DOT_EXTENSION);
            FileOutputStream tmpDotOutputStream = null;
            try {
                IOUtils.copy(input, dotContents);
                tmpDotOutputStream = new FileOutputStream(dotInput);
                IOUtils.copy(new ByteArrayInputStream(dotContents.toByteArray()), tmpDotOutputStream);
            } finally {
                IOUtils.closeQuietly(tmpDotOutputStream);
            }
            IStatus result = runDot(format, dimension, dotInput, dotOutput);
            if (dotOutput.isFile()) {
                if (!result.isOK() && Platform.inDebugMode()) LogUtils.log(status);
                return;
            }
        } catch (IOException e) {
            status.add(new Status(IStatus.ERROR, GraphVizActivator.ID, "", e));
        } finally {
            dotInput.delete();
            IOUtils.closeQuietly(input);
        }
        throw new CoreException(status);
    }