semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
@Override
    public HttpResponse execute() throws IOException {
        URL _url = getUrl();
        if (_url == null) throw new IOException("url not set");
        Proxy _proxy = getProxy();
        URLConnection urlConn = _proxy == null ? _url.openConnection() : _url.openConnection(_proxy);
        HttpURLConnection httpUrlConn = urlConn instanceof HttpURLConnection ? (HttpURLConnection) urlConn : null;
        HttpsURLConnection httpsUrlConn = urlConn instanceof HttpsURLConnection ? (HttpsURLConnection) urlConn : null;
        if (httpUrlConn != null) {
            String reqMethod = getRequestMethod();
            httpUrlConn.setRequestMethod(reqMethod);
        }
        if (httpsUrlConn != null) {
            SSLSocketFactory sslF = getSSLSocketFactory();
            if (sslF != null) httpsUrlConn.setSSLSocketFactory(sslF);
        }
        setRequestHeader(urlConn);
        String contType = getContentType();
        int len = getContentLength();
        InputStream postDataStream = getContentInputStream();
        if (contType != null && postDataStream != null) urlConn.setRequestProperty(HttpHeaders.contentType, contType);
        if (len >= 0 && postDataStream != null) urlConn.setRequestProperty(HttpHeaders.contentLength, "" + len);
        urlConn.setDoInput(true);
        urlConn.setDoOutput(postDataStream != null);
        urlConn.setUseCaches(isUseCaches());
        urlConn.setConnectTimeout(getConnectTimeout());
        urlConn.setReadTimeout(getReadTimeout());
        if (getInstanceFollowRedirects() != null && httpUrlConn != null) {
            httpUrlConn.setInstanceFollowRedirects(getInstanceFollowRedirects());
        }
        if (getIfModifiedSince() != null && httpUrlConn != null) {
            httpUrlConn.setIfModifiedSince(getIfModifiedSince());
        }
        urlConn.connect();
        if (postDataStream != null) {
            OutputStream output = urlConn.getOutputStream();
            FileUtil.copyAllData(postDataStream, output);
            output.flush();
            output.close();
            postDataStream.close();
        }
        HttpResponse response = createResponse(urlConn);
        if (isDisconnect() && httpUrlConn != null) {
            httpUrlConn.disconnect();
        }
        return response;
    }
private static StringBuffer downloadHTTPPage(URL url) throws Exception {
        URLConnection con = url.openConnection();
        con.setReadTimeout(0);
        StringBuffer sb = new StringBuffer();
        BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String line = null;
        while (null != (line = br.readLine())) {
            sb.append(line);
        }
        br.close();
        return sb;
    }
private String fetch(String urlstring) {
        String content = "";
        try {
            URL url = new URL(urlstring);
            InputStream is = url.openStream();
            BufferedReader d = new BufferedReader(new InputStreamReader(is));
            String s;
            while (null != (s = d.readLine())) {
                content = content + s + "\n";
            }
            is.close();
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        return content;
    }
public static String[] getURLListFromResource(String resourceName, String regExFilter, boolean firstNoEmptyMatched) {
        String[] urlArray;
        Vector<String> urlVector = new Vector<String>();
        try {
            ClassLoader classLoader = MqatMain.class.getClassLoader();
            URLClassLoader urlClassLoader = (URLClassLoader) classLoader;
            Enumeration e = urlClassLoader.findResources(resourceName);
            for (; e.hasMoreElements(); ) {
                URL url = (URL) e.nextElement();
                if ("file".equals(url.getProtocol())) {
                    File file = new File(url.getPath());
                    File[] fileList = file.listFiles();
                    if (fileList != null) {
                        for (int i = 0; i < fileList.length; i++) {
                            String urlStr = fileList[i].toURL().toString();
                            if (urlStr.matches(regExFilter)) {
                                urlVector.add(urlStr);
                            }
                        }
                    }
                } else if ("jar".equals(url.getProtocol())) {
                    JarURLConnection jarConnection = (JarURLConnection) url.openConnection();
                    JarFile jarFile = jarConnection.getJarFile();
                    Enumeration jarEntries = jarFile.entries();
                    for (; jarEntries.hasMoreElements(); ) {
                        JarEntry jarEntry = (JarEntry) jarEntries.nextElement();
                        if (!jarEntry.isDirectory()) {
                            String urlStr = url.toString().substring(0, url.toString().lastIndexOf('!') + 1);
                            urlStr += "/" + jarEntry;
                            if (urlStr.matches(regExFilter)) {
                                urlVector.add(urlStr);
                            }
                        }
                    }
                }
                if (!urlVector.isEmpty() && firstNoEmptyMatched) {
                    break;
                }
            }
        } catch (Exception ex) {
            ExceptionHandler.handle(ex, ExceptionHandler.NO_VISUAL);
        }
        urlArray = urlVector.toArray(new String[urlVector.size()]);
        return urlArray;
    }
private String copyTutorial() throws IOException {
        File inputFile = new File(getFilenameForOriginalTutorial());
        File outputFile = new File(getFilenameForCopiedTutorial());
        FileReader in = new FileReader(inputFile);
        FileWriter out = new FileWriter(outputFile);
        int c;
        while ((c = in.read()) != -1) out.write(c);
        in.close();
        out.close();
        return getFilenameForCopiedTutorial();
    }
public static String crypt(String senha) {
        String md5 = null;
        MessageDigest md;
        try {
            md = MessageDigest.getInstance(CRYPT_ALGORITHM);
            md.update(senha.getBytes());
            Hex hex = new Hex();
            md5 = new String(hex.encode(md.digest()));
        } catch (NoSuchAlgorithmException e) {
            logger.error(ResourceUtil.getLOGMessage("_nls.mensagem.geral.log.crypt.no.such.algorithm", CRYPT_ALGORITHM));
        }
        return md5;
    }
public static void copy(File src, File dst) throws IOException {
        FileInputStream fIn = null;
        FileOutputStream fOut = null;
        FileChannel sIn = null;
        FileChannel sOut = null;
        try {
            fIn = new FileInputStream(src);
            try {
                fOut = new FileOutputStream(dst);
                try {
                    sIn = fIn.getChannel();
                    sOut = fOut.getChannel();
                    sOut.transferFrom(sIn, 0, sIn.size());
                } finally {
                    if (sIn != null) {
                        sIn.close();
                    }
                    if (sOut != null) {
                        sOut.close();
                    }
                }
            } finally {
                if (fOut != null) {
                    fOut.close();
                }
            }
        } finally {
            if (fIn != null) {
                fIn.close();
            }
        }
    }
private static ArrayList<String> YahooSearch(String query) {
        ArrayList<String> yahooSearchResults = new ArrayList<String>();
        try {
            String request = "http://boss.yahooapis.com/ysearch/web/v1/" + URLEncoder.encode("Java example for " + query, "UTF-8") + "?appid=zfau5aPV34ETbq9mWU0ui5e04y0rIewg1zwvzHb1tGoBFK2nSCU1SKS2D4zphh2rd3Wf" + "&format=xml&count=30&type=-msoffice,-pdf";
            URL url = new URL(request);
            System.out.println("Host : " + url.getHost());
            url.openConnection();
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
            String inputLine;
            String finalContents = "";
            while ((inputLine = reader.readLine()) != null) {
                finalContents += "\n" + inputLine;
            }
            Document doc = Jsoup.parse(finalContents);
            Elements eles = doc.getElementsByTag("url");
            for (Element ele : eles) {
                yahooSearchResults.add(ele.text());
                System.out.println("YahooResult: " + ele.text());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return yahooSearchResults;
    }
private String getAuthUrlString(String account, String password) throws IOException, NoSuchAlgorithmException {
        Map<String, String> dict = retrieveLoginPage();
        if (dict == null) {
            return null;
        }
        StringBuilder url = new StringBuilder("/config/login?login=");
        url.append(account);
        url.append("&passwd=");
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        md5.update(password.getBytes(), 0, password.length());
        byte[] result = md5.digest();
        for (int i = 0; i < 16; i++) {
            url.append(StringUtil.toHex2(result[i]));
        }
        String md5chal = dict.get(".challenge");
        md5 = MessageDigest.getInstance("MD5");
        md5.update(md5chal.getBytes(), 0, md5chal.length());
        result = md5.digest();
        for (int i = 0; i < 16; i++) {
            url.append(StringUtil.toHex2(result[i]));
        }
        Iterator<String> j = dict.keySet().iterator();
        while (j.hasNext()) {
            String key = j.next();
            String value = dict.get(key);
            if (!key.equals("passwd")) {
                if (key.equals(".save") || key.equals(".js")) {
                    url.append("&" + key + "=1");
                } else if (key.equals(".challenge")) {
                    url.append("&" + key + "=" + value);
                } else {
                    String u = URLEncoder.encode(value, "UTF-8");
                    url.append("&" + key + "=" + u);
                }
            }
        }
        url.append("&");
        url.append(".hash=1");
        url.append("&");
        url.append(".md5=1");
        return url.toString();
    }
static List<String> readZipFilesOftypeToFolder(String zipFileLocation, String outputDir, String fileType) {
        List<String> list = new ArrayList<String>();
        ZipFile zipFile = readZipFile(zipFileLocation);
        FileOutputStream output = null;
        InputStream inputStream = null;
        Enumeration<ZipEntry> entries = (Enumeration<ZipEntry>) zipFile.entries();
        try {
            while (entries.hasMoreElements()) {
                java.util.zip.ZipEntry entry = entries.nextElement();
                String entryName = entry.getName();
                if (entryName != null && entryName.toLowerCase().endsWith(fileType)) {
                    inputStream = zipFile.getInputStream(entry);
                    String fileName = outputDir + entryName.substring(entryName.lastIndexOf("/"));
                    File file = new File(fileName);
                    output = new FileOutputStream(file);
                    IOUtils.copy(inputStream, output);
                    list.add(fileName);
                }
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            try {
                if (output != null) output.close();
                if (inputStream != null) inputStream.close();
                if (zipFile != null) zipFile.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return list;
    }
public boolean setTraceUrl(String s) {
        try {
            url = new URL(s);
            istream = url.openConnection();
            last_contentLenght = 0;
            reader = new BufferedReader(new InputStreamReader(istream.getInputStream()));
        } catch (MalformedURLException malformedurlexception) {
            System.out.println("Trace2Png: MalformedURLException: " + s);
            return false;
        } catch (IOException ioexception) {
            System.out.println("Trace2Png: IOException: " + s);
            return false;
        }
        trace = t2pNewTrace();
        return true;
    }
public int readLines() {
        int i = 0;
        if (istream == null) return 0;
        try {
            String s1;
            if ((new String("http")).compareTo(url.getProtocol()) == 0) {
                istream = url.openConnection();
                if (last_contentLenght != istream.getContentLength()) {
                    last_contentLenght = istream.getContentLength();
                    istream = url.openConnection();
                    istream.setRequestProperty("Range", "bytes=" + Integer.toString(bytes_read) + "-");
                    System.out.println("Trace2Png: ContentLength: " + Integer.toString(istream.getContentLength()));
                    reader = new BufferedReader(new InputStreamReader(istream.getInputStream()));
                    String s;
                    while ((s = reader.readLine()) != null) {
                        bytes_read = bytes_read + s.length() + 1;
                        t2pProcessLine(trace, s);
                        i++;
                    }
                }
            } else {
                while ((s1 = reader.readLine()) != null) {
                    bytes_read = bytes_read + s1.length() + 1;
                    t2pProcessLine(trace, s1);
                    i++;
                }
            }
            t2pHandleEventPairs(trace);
            t2pSort(trace, sortby);
        } catch (IOException ioexception) {
            System.out.println("Trace2Png: IOException !!!");
        }
        return i;
    }
public static void copyFile(File src, File dst) throws IOException {
        LOGGER.info("Copying file '" + src.getAbsolutePath() + "' to '" + dst.getAbsolutePath() + "'");
        FileChannel in = null;
        FileChannel out = null;
        try {
            FileInputStream fis = new FileInputStream(src);
            in = fis.getChannel();
            FileOutputStream fos = new FileOutputStream(dst);
            out = fos.getChannel();
            out.transferFrom(in, 0, in.size());
        } finally {
            try {
                if (in != null) in.close();
            } catch (IOException e) {
                LOGGER.log(Level.SEVERE, e.getMessage(), e);
            }
            if (out != null) {
                try {
                    out.close();
                } catch (IOException e) {
                    LOGGER.log(Level.SEVERE, e.getMessage(), e);
                }
            }
        }
    }
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listview);
        HttpGet request = new HttpGet(SERVICE_URI + "/json/getroutes/1");
        request.setHeader("Accept", "application/json");
        request.setHeader("Content-type", "application/json");
        DefaultHttpClient httpClient = new DefaultHttpClient();
        String theString = new String("");
        try {
            HttpResponse response = httpClient.execute(request);
            HttpEntity responseEntity = response.getEntity();
            InputStream stream = responseEntity.getContent();
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
            Vector<String> vectorOfStrings = new Vector<String>();
            String tempString = new String();
            String tempStringAgent = new String();
            String tempStringClient = new String();
            String tempStringRoute = new String();
            String tempStringZone = new String();
            StringBuilder builder = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                builder.append(line);
            }
            stream.close();
            theString = builder.toString();
            JSONObject json = new JSONObject(theString);
            Log.i("_GetClient_", "<jsonobject> \n " + json.toString() + " \n </jsonobject>");
            this.dm = new DataManipulator(this);
            JSONArray nameArray = json.getJSONArray("GetRoutesByAgentResult");
            for (int i = 0; i < nameArray.length(); i++) {
                tempStringAgent = nameArray.getJSONObject(i).getString("Agent");
                tempStringClient = nameArray.getJSONObject(i).getString("Client");
                tempStringRoute = nameArray.getJSONObject(i).getString("Route");
                tempStringZone = nameArray.getJSONObject(i).getString("Zone");
                Log.i("_GetClient_", "<Agent" + i + ">" + tempStringAgent + "</Agent" + i + ">\n");
                Log.i("_GetClient_", "<Client" + i + ">" + tempStringClient + "</Client" + i + ">\n");
                Log.i("_GetClient_", "<Route" + i + ">" + tempStringRoute + "</Route" + i + ">\n");
                Log.i("_GetClient_", "<Zone" + i + ">" + tempStringZone + "</Zone" + i + ">\n");
                this.dm.insertIntoClients(tempStringAgent, tempStringClient, tempStringRoute, tempStringZone);
                tempString = nameArray.getJSONObject(i).getString("Client") + "\n" + nameArray.getJSONObject(i).getString("Route") + "\n" + nameArray.getJSONObject(i).getString("Zone");
                vectorOfStrings.add(new String(tempString));
            }
            int orderCount = vectorOfStrings.size();
            String[] orderTimeStamps = new String[orderCount];
            vectorOfStrings.copyInto(orderTimeStamps);
            setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, orderTimeStamps));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
public static void nuovoAcquisto(int quantita, Date d, double price, int id) throws SQLException {
        MyDBConnection c = new MyDBConnection();
        c.init();
        Connection conn = c.getMyConnection();
        PreparedStatement ps = conn.prepareStatement(insertAcquisto);
        ps.setInt(1, quantita);
        ps.setDate(2, d);
        ps.setDouble(3, price);
        ps.setInt(4, id);
        ps.executeUpdate();
        double newPrice = price;
        int newQ = quantita;
        ResultSet rs = MyDBConnection.executeQuery(queryPrezzo.replace("?", "" + id), conn);
        if (rs.next()) {
            int oldQ = rs.getInt(1);
            double oldPrice = rs.getDouble(2);
            newQ = quantita + oldQ;
            newPrice = (oldPrice * oldQ + price * quantita) / newQ;
            updatePortafoglio(conn, newPrice, newQ, id);
        } else insertPortafoglio(conn, id, newPrice, newQ);
        try {
            conn.commit();
        } catch (SQLException e) {
            conn.rollback();
            throw new SQLException("Effettuato rollback dopo " + e.getMessage());
        } finally {
            c.close();
        }
    }
public static boolean update(String user, String pass, String channelString, String globalIP) {
        FTPClient ftp = new FTPClient();
        int reply;
        try {
            ftp.connect("witna.co.uk", 21);
            ftp.login(user, pass);
            reply = ftp.getReplyCode();
            if (FTPReply.isPositiveCompletion(reply)) {
                updateChannelList(ftp, channelString);
                if (!ipUpdated) {
                    ipUpdated = updateMasterChannelIP(ftp, globalIP);
                }
                ftp.disconnect();
                return true;
            } else {
                ftp.disconnect();
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return false;
    }
public void setPassword(String plaintext) throws java.security.NoSuchAlgorithmException {
        StringBuffer encrypted = new StringBuffer();
        java.security.MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
        digest.update(plaintext.getBytes());
        byte[] digestArray = digest.digest();
        for (int i = 0; i < digestArray.length; i++) {
            encrypted.append(byte2hex(digestArray[i]));
        }
        setEncryptedPassword(encrypted.toString());
    }
public static List importDate(Report report, TradingDate date) throws ImportExportException {
        List quotes = new ArrayList();
        String urlString = constructURL(date);
        EODQuoteFilter filter = new MetaStockQuoteFilter();
        PreferencesManager.ProxyPreferences proxyPreferences = PreferencesManager.getProxySettings();
        try {
            URL url = new URL(urlString);
            InputStreamReader input = new InputStreamReader(url.openStream());
            BufferedReader bufferedInput = new BufferedReader(input);
            String line = null;
            do {
                line = bufferedInput.readLine();
                if (line != null) {
                    try {
                        EODQuote quote = filter.toEODQuote(line);
                        quotes.add(quote);
                        verify(report, quote);
                    } catch (QuoteFormatException e) {
                        report.addError(Locale.getString("DFLOAT_DISPLAY_URL") + ":" + date + ":" + Locale.getString("ERROR") + ": " + e.getMessage());
                    }
                }
            } while (line != null);
            bufferedInput.close();
        } catch (BindException e) {
            throw new ImportExportException(Locale.getString("UNABLE_TO_CONNECT_ERROR", e.getMessage()));
        } catch (ConnectException e) {
            throw new ImportExportException(Locale.getString("UNABLE_TO_CONNECT_ERROR", e.getMessage()));
        } catch (UnknownHostException e) {
            throw new ImportExportException(Locale.getString("UNKNOWN_HOST_ERROR", e.getMessage()));
        } catch (NoRouteToHostException e) {
            throw new ImportExportException(Locale.getString("DESTINATION_UNREACHABLE_ERROR", e.getMessage()));
        } catch (MalformedURLException e) {
            throw new ImportExportException(Locale.getString("INVALID_PROXY_ERROR", proxyPreferences.host, proxyPreferences.port));
        } catch (FileNotFoundException e) {
            report.addError(Locale.getString("FLOAT_DISPLAY_URL") + ":" + date + ":" + Locale.getString("ERROR") + ": " + Locale.getString("NO_QUOTES_FOUND"));
        } catch (IOException e) {
            throw new ImportExportException(Locale.getString("ERROR_DOWNLOADING_QUOTES"));
        }
        return quotes;
    }