semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public void run() {
        videoId = videoId.trim();
        System.out.println("fetching video");
        String requestUrl = "http://www.youtube.com/get_video_info?&video_id=" + videoId;
        try {
            URL url = new URL(requestUrl);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setDoOutput(true);
            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line = rd.readLine();
            int from = line.indexOf("&token=") + 7;
            int to = line.indexOf("&thumbnail_url=");
            String id = line.substring(from, to);
            String tmp = "http://www.youtube.com/get_video?video_id=" + videoId + "&t=" + id;
            url = new URL(tmp);
            conn = (HttpURLConnection) url.openConnection();
            rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            rd.readLine();
            tmp = conn.getURL().toString();
            url = new URL(tmp);
            conn = (HttpURLConnection) url.openConnection();
            InputStream is;
            OutputStream outStream;
            URLConnection uCon;
            byte[] buf;
            int ByteRead, ByteWritten = 0;
            url = new URL(tmp);
            outStream = new BufferedOutputStream(new FileOutputStream(videoId + ".flv"));
            uCon = url.openConnection();
            is = uCon.getInputStream();
            buf = new byte[1024];
            while ((ByteRead = is.read(buf)) != -1) {
                outStream.write(buf, 0, ByteRead);
                ByteWritten += ByteRead;
            }
            is.close();
            outStream.close();
            System.out.println(videoUrl + " is ready");
        } catch (Exception e) {
            System.out.println("Could not find flv-url " + videoId + "! " + e.getMessage());
        } finally {
            ready = true;
        }
    }
public static String hashPassword(String password) {
        String hashStr = null;
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(password.getBytes(Charset.defaultCharset()));
            BigInteger hash = new BigInteger(1, md5.digest());
            hashStr = hash.toString(16);
        } catch (NoSuchAlgorithmException e) {
            return password;
        }
        StringBuilder buffer = new StringBuilder(hashStr);
        while (buffer.length() < 32) {
            buffer.insert(0, '0');
        }
        return buffer.toString();
    }
public static String createStringFromHtml(MyUrl url) {
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.getUrl().openStream(), "UTF-8"));
            String line;
            String xmlAsString = "";
            while ((line = reader.readLine()) != null) {
                xmlAsString += line;
            }
            reader.close();
            return xmlAsString;
        } catch (Exception e) {
            return null;
        }
    }
private void doUpload(UploadKind uploadKind, WriteKind writeKind) throws Exception {
        int n = 512 * 1024;
        AtomicInteger total = new AtomicInteger(0);
        ServerSocket ss = startSinkServer(total);
        URL url = new URL("http://localhost:" + ss.getLocalPort() + "/test1");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.setDoOutput(true);
        conn.setRequestMethod("POST");
        if (uploadKind == UploadKind.CHUNKED) {
            conn.setChunkedStreamingMode(-1);
        } else {
            conn.setFixedLengthStreamingMode(n);
        }
        OutputStream out = conn.getOutputStream();
        if (writeKind == WriteKind.BYTE_BY_BYTE) {
            for (int i = 0; i < n; ++i) {
                out.write('x');
            }
        } else {
            byte[] buf = new byte[writeKind == WriteKind.SMALL_BUFFERS ? 256 : 64 * 1024];
            Arrays.fill(buf, (byte) 'x');
            for (int i = 0; i < n; i += buf.length) {
                out.write(buf, 0, Math.min(buf.length, n - i));
            }
        }
        out.close();
        assertTrue(conn.getResponseCode() > 0);
        assertEquals(uploadKind == UploadKind.CHUNKED ? -1 : n, total.get());
    }
protected void channelConnected() throws IOException {
        MessageDigest md = null;
        String digest = "";
        try {
            String userid = nateon.getUserId();
            if (userid.endsWith("@nate.com")) userid = userid.substring(0, userid.lastIndexOf('@'));
            md = MessageDigest.getInstance("MD5");
            md.update(nateon.getPassword().getBytes());
            md.update(userid.getBytes());
            byte[] bData = md.digest();
            StringBuilder sb = new StringBuilder();
            for (byte b : bData) {
                int v = (int) b;
                v = v < 0 ? v + 0x100 : v;
                String s = Integer.toHexString(v);
                if (s.length() == 1) sb.append('0');
                sb.append(s);
            }
            digest = sb.toString();
        } catch (Exception e) {
            e.printStackTrace();
        }
        NateOnMessage out = new NateOnMessage("LSIN");
        out.add(nateon.getUserId()).add(digest).add("MD5").add("3.615");
        out.setCallback("processAuth");
        writeMessage(out);
    }
private File getDvdDataFileFromWeb() throws IOException {
        System.out.println("Downloading " + dvdCsvFileUrl);
        URL url = new URL(dvdCsvFileUrl);
        URLConnection conn = url.openConnection();
        InputStream in = conn.getInputStream();
        OutputStream out = new FileOutputStream(dvdCsvZipFileName);
        writeFromTo(in, out);
        System.out.println("Extracting " + dvdCsvFileName + " from " + dvdCsvZipFileName);
        File dvdZipFile = new File(dvdCsvZipFileName);
        File dvdCsvFile = new File(dvdCsvFileName);
        ZipFile zipFile = new ZipFile(dvdZipFile);
        ZipEntry zipEntry = zipFile.getEntry(dvdCsvFileName);
        FileOutputStream os = new FileOutputStream(dvdCsvFile);
        InputStream is = zipFile.getInputStream(zipEntry);
        writeFromTo(is, os);
        System.out.println("Deleting zip file");
        dvdZipFile.delete();
        System.out.println("Dvd csv file download complete");
        return dvdCsvFile;
    }
protected InputStream getInputStream(URL url) {
        InputStream is = null;
        if (url != null) {
            try {
                is = url.openStream();
            } catch (Exception ex) {
            }
        }
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        if (is == null) {
            try {
                is = classLoader.getResourceAsStream("osworkflow.xml");
            } catch (Exception e) {
            }
        }
        if (is == null) {
            try {
                is = classLoader.getResourceAsStream("/osworkflow.xml");
            } catch (Exception e) {
            }
        }
        if (is == null) {
            try {
                is = classLoader.getResourceAsStream("META-INF/osworkflow.xml");
            } catch (Exception e) {
            }
        }
        if (is == null) {
            try {
                is = classLoader.getResourceAsStream("/META-INF/osworkflow.xml");
            } catch (Exception e) {
            }
        }
        return is;
    }
private void getViolationsReportByProductOfferIdYearMonth() throws IOException {
        String xmlFile8Send = System.getenv("SLASOI_HOME") + System.getProperty("file.separator") + "Integration" + System.getProperty("file.separator") + "soap" + System.getProperty("file.separator") + "getViolationsReportByProductOfferIdYearMonth.xml";
        URL url8;
        url8 = new URL(bmReportingWSUrl);
        URLConnection connection8 = url8.openConnection();
        HttpURLConnection httpConn8 = (HttpURLConnection) connection8;
        FileInputStream fin8 = new FileInputStream(xmlFile8Send);
        ByteArrayOutputStream bout8 = new ByteArrayOutputStream();
        SOAPClient4XG.copy(fin8, bout8);
        fin8.close();
        byte[] b8 = bout8.toByteArray();
        httpConn8.setRequestProperty("Content-Length", String.valueOf(b8.length));
        httpConn8.setRequestProperty("Content-Type", "application/soap+xml; charset=UTF-8");
        httpConn8.setRequestProperty("SOAPAction", soapAction);
        httpConn8.setRequestMethod("POST");
        httpConn8.setDoOutput(true);
        httpConn8.setDoInput(true);
        OutputStream out8 = httpConn8.getOutputStream();
        out8.write(b8);
        out8.close();
        InputStreamReader isr8 = new InputStreamReader(httpConn8.getInputStream());
        BufferedReader in8 = new BufferedReader(isr8);
        String inputLine8;
        StringBuffer response8 = new StringBuffer();
        while ((inputLine8 = in8.readLine()) != null) {
            response8.append(inputLine8);
        }
        in8.close();
        System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + "####################################################" + "#################################################\n" + "####################################################" + "#################################################\n" + "Component Name: Business Manager\n" + "Interface Name: getReport\n" + "Operation Name:" + "getViolationsReportByProductOfferIdYearMonth\n" + "Input" + "ProductOfferID-1\n" + "PartyID-1\n" + "\n" + "####################################################" + "#################################################\n" + "####################################################" + "#################################################\n" + "######################################## RESPONSE" + "############################################\n\n");
        System.out.println("--------------------------------");
        System.out.println("Response\n" + response8.toString());
    }
private void getViolationsReportByProductOfferIdYearMonthDay() throws IOException {
        String xmlFile9Send = System.getenv("SLASOI_HOME") + System.getProperty("file.separator") + "Integration" + System.getProperty("file.separator") + "soap" + System.getProperty("file.separator") + "getViolationsReportByProductOfferIdYearMonthDay.xml";
        URL url9;
        url9 = new URL(bmReportingWSUrl);
        URLConnection connection9 = url9.openConnection();
        HttpURLConnection httpConn9 = (HttpURLConnection) connection9;
        FileInputStream fin9 = new FileInputStream(xmlFile9Send);
        ByteArrayOutputStream bout9 = new ByteArrayOutputStream();
        SOAPClient4XG.copy(fin9, bout9);
        fin9.close();
        byte[] b9 = bout9.toByteArray();
        httpConn9.setRequestProperty("Content-Length", String.valueOf(b9.length));
        httpConn9.setRequestProperty("Content-Type", "application/soap+xml; charset=UTF-8");
        httpConn9.setRequestProperty("SOAPAction", soapAction);
        httpConn9.setRequestMethod("POST");
        httpConn9.setDoOutput(true);
        httpConn9.setDoInput(true);
        OutputStream out9 = httpConn9.getOutputStream();
        out9.write(b9);
        out9.close();
        InputStreamReader isr9 = new InputStreamReader(httpConn9.getInputStream());
        BufferedReader in9 = new BufferedReader(isr9);
        String inputLine9;
        StringBuffer response9 = new StringBuffer();
        while ((inputLine9 = in9.readLine()) != null) {
            response9.append(inputLine9);
        }
        in9.close();
        System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + "####################################################" + "#################################################\n" + "####################################################" + "#################################################\n" + "Component Name: Business Manager\n" + "Interface Name: getReport\n" + "Operation Name: " + "getViolationsReportByProductOfferIdYearMonthDay\n" + "Input" + "ProductOfferID-1\n" + "PartyID-1\n" + "\n" + "####################################################" + "#################################################\n" + "####################################################" + "#################################################\n" + "######################################## RESPONSE" + "############################################\n\n");
        System.out.println("--------------------------------");
        System.out.println("Response\n" + response9.toString());
    }
private void getViolationsReportBySLATIdYearMonth() throws IOException {
        String xmlFile10Send = System.getenv("SLASOI_HOME") + System.getProperty("file.separator") + "Integration" + System.getProperty("file.separator") + "soap" + System.getProperty("file.separator") + "getViolationsReportBySLATIdYearMonth.xml";
        URL url10;
        url10 = new URL(bmReportingWSUrl);
        URLConnection connection10 = url10.openConnection();
        HttpURLConnection httpConn10 = (HttpURLConnection) connection10;
        FileInputStream fin10 = new FileInputStream(xmlFile10Send);
        ByteArrayOutputStream bout10 = new ByteArrayOutputStream();
        SOAPClient4XG.copy(fin10, bout10);
        fin10.close();
        byte[] b10 = bout10.toByteArray();
        httpConn10.setRequestProperty("Content-Length", String.valueOf(b10.length));
        httpConn10.setRequestProperty("Content-Type", "application/soap+xml; charset=UTF-8");
        httpConn10.setRequestProperty("SOAPAction", soapAction);
        httpConn10.setRequestMethod("POST");
        httpConn10.setDoOutput(true);
        httpConn10.setDoInput(true);
        OutputStream out10 = httpConn10.getOutputStream();
        out10.write(b10);
        out10.close();
        InputStreamReader isr10 = new InputStreamReader(httpConn10.getInputStream());
        BufferedReader in10 = new BufferedReader(isr10);
        String inputLine10;
        StringBuffer response10 = new StringBuffer();
        while ((inputLine10 = in10.readLine()) != null) {
            response10.append(inputLine10);
        }
        in10.close();
        System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + "####################################################" + "#################################################\n" + "####################################################" + "#################################################\n" + "Component Name: Business Manager\n" + "Interface Name: getReport\n" + "Operation Name: getViolationsReportBySLATIdYearMonth\n" + "Input" + "ProductOfferID-1\n" + "PartyID-1\n" + "\n" + "####################################################" + "#################################################\n" + "####################################################" + "#################################################\n" + "######################################## RESPONSE" + "############################################\n\n");
        System.out.println("--------------------------------");
        System.out.println("Response\n" + response10.toString());
    }
private void getViolationsReportBySLATIdYearMonthDay() throws IOException {
        String xmlFile11Send = System.getenv("SLASOI_HOME") + System.getProperty("file.separator") + "Integration" + System.getProperty("file.separator") + "soap" + System.getProperty("file.separator") + "getViolationsReportBySLATIdYearMonthDay.xml";
        URL url11;
        url11 = new URL(bmReportingWSUrl);
        URLConnection connection11 = url11.openConnection();
        HttpURLConnection httpConn11 = (HttpURLConnection) connection11;
        FileInputStream fin11 = new FileInputStream(xmlFile11Send);
        ByteArrayOutputStream bout11 = new ByteArrayOutputStream();
        SOAPClient4XG.copy(fin11, bout11);
        fin11.close();
        byte[] b11 = bout11.toByteArray();
        httpConn11.setRequestProperty("Content-Length", String.valueOf(b11.length));
        httpConn11.setRequestProperty("Content-Type", "application/soap+xml; charset=UTF-8");
        httpConn11.setRequestProperty("SOAPAction", soapAction);
        httpConn11.setRequestMethod("POST");
        httpConn11.setDoOutput(true);
        httpConn11.setDoInput(true);
        OutputStream out11 = httpConn11.getOutputStream();
        out11.write(b11);
        out11.close();
        InputStreamReader isr11 = new InputStreamReader(httpConn11.getInputStream());
        BufferedReader in11 = new BufferedReader(isr11);
        String inputLine11;
        StringBuffer response11 = new StringBuffer();
        while ((inputLine11 = in11.readLine()) != null) {
            response11.append(inputLine11);
        }
        in11.close();
        System.out.println("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" + "####################################################" + "#################################################\n" + "####################################################" + "#################################################\n" + "Component Name: Business Manager\n" + "Interface Name: getReport\n" + "Operation Name: getViolationsReportBySLATIdYearMonthDay\n" + "Input" + "ProductOfferID-1\n" + "PartyID-1\n" + "\n" + "####################################################" + "#################################################\n" + "####################################################" + "#################################################\n" + "######################################## RESPONSE" + "############################################\n\n");
        System.out.println("--------------------------------");
        System.out.println("Response\n" + response11.toString());
    }
public void open() throws IOException, RecursionException {
        String encoding = null;
        if (source != null) {
            Reader sourceReader = source.getCharacterStream();
            if (sourceReader != null) {
                if (readerReader == null) readerReader = new XMLReaderReader();
                readerReader.reset(sourceReader, true);
                isStandalone = readerReader.isXMLStandalone();
                activeReader = readerReader;
                isOpen = true;
                return;
            }
            InputStream in = source.getByteStream();
            if (in != null) {
                if (streamReader == null) streamReader = new XMLStreamReader();
                streamReader.reset(in, source.getEncoding(), true);
                isOpen = true;
                isStandalone = streamReader.isXMLStandalone();
                activeReader = streamReader;
                return;
            }
            url = new URL(defaultContext, source.getSystemId());
            sysID = url.toString();
            encoding = source.getEncoding();
        }
        if (streamReader == null) streamReader = new XMLStreamReader();
        streamReader.reset(url.openStream(), encoding, true);
        isStandalone = streamReader.isXMLStandalone();
        activeReader = streamReader;
        isOpen = true;
    }
@Override
    public BufferedImageAndBytes load(T thing) {
        String iurl = resolver.getUrl(thing);
        URL url;
        for (int k = 0; k < nTries; k++) {
            if (k > 0) {
                logger.debug("retry #" + k);
            }
            try {
                url = new URL(iurl);
                URLConnection connection = url.openConnection();
                if (userAgent != null) {
                    connection.setRequestProperty("User-Agent", userAgent);
                }
                InputStream is = new BufferedInputStream(connection.getInputStream());
                ByteArrayOutputStream baos = new ByteArrayOutputStream(40000);
                int b;
                while ((b = is.read()) != -1) {
                    baos.write(b);
                }
                is.close();
                byte[] bytes = baos.toByteArray();
                ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
                BufferedImage image = ImageIO.read(bais);
                return new BufferedImageAndBytes(image, bytes);
            } catch (MalformedURLException e) {
                continue;
            } catch (IOException e) {
                continue;
            }
        }
        return null;
    }
public boolean ImportData() {
        if (fileData == null) {
            return false;
        }
        String line = new String();
        BufferedReader br;
        BufferedWriter bw;
        String tableName = new String();
        List<String> columns = new ArrayList<String>();
        long recordsNumber;
        String sql = new String();
        File tempDataFile;
        String filePath = new String();
        try {
            br = new BufferedReader(new InputStreamReader(new FileInputStream(fileData)));
            if (br.ready()) {
                if ((line = br.readLine()) != null) {
                    do {
                        tableName = siteName + "_" + getTableName(line);
                        columns = getTableColumns(line);
                        tempDataFile = new File("./Data/" + tableName + ".txt");
                        tempDataFile.createNewFile();
                        filePath = tempDataFile.getCanonicalPath();
                        sql = generateSQL(tableName, columns, filePath);
                        recordsNumber = getRecordNumber(line);
                        bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tempDataFile)));
                        for (long i = 0; i < recordsNumber; i++) {
                            bw.write(br.readLine() + "\r\n");
                        }
                        bw.close();
                        if (sqlConnector != null) {
                            sqlConnector.executeSQL(sql);
                        } else {
                            return false;
                        }
                    } while ((line = br.readLine()) != null);
                }
                br.close();
            }
        } catch (Exception e) {
            ExceptionHandler.handleExcptin(e);
        }
        return true;
    }
private Response postRequest(String urlString, String params) throws Exception {
        URL url = new URL(urlString);
        HttpURLConnection uc = (HttpURLConnection) url.openConnection();
        uc.setDoInput(true);
        uc.setDoOutput(true);
        uc.setUseCaches(false);
        uc.setAllowUserInteraction(false);
        uc.setRequestMethod("POST");
        uc.setRequestProperty("ContentType", "application/x-www-form-urlencoded");
        uc.setRequestProperty("User-Agent", "CytoLinkFromMJ");
        if (cookie != null) uc.setRequestProperty("Cookie", cookie);
        PrintStream out = new PrintStream(uc.getOutputStream());
        out.print(params);
        out.flush();
        out.close();
        uc.connect();
        StringBuffer sb = new StringBuffer();
        String inputLine;
        BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
        while ((inputLine = in.readLine()) != null) {
            sb.append(inputLine + "\n");
        }
        in.close();
        Response res = new Response();
        res.content = sb.toString();
        res.contentType = uc.getHeaderField("Content-Type");
        res.cookie = uc.getHeaderField("Set-Cookie");
        return res;
    }