semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
private void importUrl() throws ExtractaException {
        UITools.changeCursor(UITools.WAIT_CURSOR, this);
        try {
            m_sUrlString = m_urlTF.getText();
            URL url = new URL(m_sUrlString);
            Document document = DomHelper.parseHtml(url.openStream());
            m_inputPanel.setDocument(document);
            Edl edl = new Edl();
            edl.addUrlDescriptor(new UrlDescriptor(m_sUrlString));
            m_resultPanel.setContext(new ResultContext(edl, document, url));
            setModified(true);
        } catch (IOException ex) {
            throw new ExtractaException("Can not open URL!", ex);
        } finally {
            UITools.changeCursor(UITools.DEFAULT_CURSOR, this);
        }
    }
private void loadFile(File file) throws Exception {
        Edl edl = new Edl("file:///" + file.getAbsolutePath());
        URL url = ExtractaHelper.retrieveUrl(edl.getUrlRetrievalDescriptor());
        String sUrlString = url.toExternalForm();
        if (sUrlString.startsWith("file:/") && (sUrlString.charAt(6) != '/')) {
            sUrlString = sUrlString.substring(0, 6) + "//" + sUrlString.substring(6);
        }
        Document document = DomHelper.parseHtml(url.openStream());
        m_inputPanel.setDocument(document);
        m_resultPanel.setContext(new ResultContext(edl, document, url));
        initNameCounters(edl.getItemDescriptors());
        m_outputFile = file;
        m_sUrlString = sUrlString;
        m_urlTF.setText(m_sUrlString);
        updateHistroy(m_outputFile);
        setModified(false);
    }
public static void fileCopy(File source, File dest) throws IOException {
        FileChannel in = null, out = null;
        try {
            in = new FileInputStream(source).getChannel();
            out = new FileOutputStream(dest).getChannel();
            long size = in.size();
            MappedByteBuffer buf = in.map(FileChannel.MapMode.READ_ONLY, 0, size);
            out.write(buf);
        } finally {
            if (in != null) {
                in.close();
            }
            if (out != null) {
                out.close();
            }
        }
    }
private void getInfoFromXML() {
        final ProgressDialog dialog = ProgressDialog.show(this, "", getString(R.string.loading), true, true);
        setProgressBarIndeterminateVisibility(true);
        Thread t3 = new Thread() {

            public void run() {
                waiting(200);
                try {
                    URL url = new URL(urlAddress);
                    SAXParserFactory spf = SAXParserFactory.newInstance();
                    SAXParser sp = spf.newSAXParser();
                    XMLReader xr = sp.getXMLReader();
                    XMLHandlerSingleArtist myXMLHandler = new XMLHandlerSingleArtist();
                    xr.setContentHandler(myXMLHandler);
                    xr.parse(new InputSource(url.openStream()));
                    artist = myXMLHandler.artist;
                    emusicURL = myXMLHandler.url;
                    bio = myXMLHandler.bio;
                    born = myXMLHandler.born;
                    death = myXMLHandler.death;
                    decade = myXMLHandler.decade;
                    rating = myXMLHandler.rating;
                    statuscode = myXMLHandler.statuscode;
                    if (statuscode != 200 && statuscode != 206) {
                        throw new Exception();
                    }
                    handlerSetContent.sendEmptyMessage(0);
                } catch (Exception e) {
                    headerTextView.post(new Runnable() {

                        public void run() {
                            headerTextView.setText(R.string.couldnt_get_artist_info);
                        }
                    });
                }
                dialog.dismiss();
                handlerDoneLoading.sendEmptyMessage(0);
            }
        };
        t3.start();
    }
@Override
    public URLConnection openConnection(URL url) throws IOException {
        if (!url.getProtocol().equals("file")) {
            String name = url.getFile();
            File f = new File(cacheFolder, ((name.charAt(0) == '/') ? name.substring(1) : name).replace('/', File.separatorChar));
            if (!f.exists()) {
                File f2 = new File(f.getParentFile(), f.getName() + "-not_found");
                if (!f2.exists()) {
                    try {
                        f.getParentFile().mkdirs();
                        downloadFile(url, f);
                    } catch (IOException e) {
                        f.delete();
                        throw e;
                    }
                }
            }
            return f.toURI().toURL().openConnection();
        }
        return super.openConnection(url);
    }
@Override
    public void execute(Client client, TaskProperties properties, TaskLog taskLog) throws SearchLibException {
        String url = properties.getValue(propUrl);
        URI uri;
        try {
            uri = new URI(url);
        } catch (URISyntaxException e) {
            throw new SearchLibException(e);
        }
        String login = properties.getValue(propLogin);
        String password = properties.getValue(propPassword);
        String instanceId = properties.getValue(propInstanceId);
        HttpParams params = new BasicHttpParams();
        HttpProtocolParamBean paramsBean = new HttpProtocolParamBean(params);
        paramsBean.setVersion(HttpVersion.HTTP_1_1);
        paramsBean.setContentCharset("UTF-8");
        HttpClientParams.setRedirecting(params, true);
        DefaultHttpClient httpClient = new DefaultHttpClient(params);
        CredentialsProvider credential = httpClient.getCredentialsProvider();
        if (login != null && login.length() > 0 && password != null && password.length() > 0) credential.setCredentials(new AuthScope(uri.getHost(), uri.getPort()), new UsernamePasswordCredentials(login, password)); else credential.clear();
        HttpPost httpPost = new HttpPost(uri);
        MultipartEntity reqEntity = new MultipartEntity();
        new Monitor().writeToPost(reqEntity);
        try {
            reqEntity.addPart("instanceId", new StringBody(instanceId));
        } catch (UnsupportedEncodingException e) {
            throw new SearchLibException(e);
        }
        httpPost.setEntity(reqEntity);
        try {
            HttpResponse httpResponse = httpClient.execute(httpPost);
            HttpEntity resEntity = httpResponse.getEntity();
            StatusLine statusLine = httpResponse.getStatusLine();
            EntityUtils.consume(resEntity);
            if (statusLine.getStatusCode() != 200) throw new SearchLibException("Wrong code status:" + statusLine.getStatusCode() + " " + statusLine.getReasonPhrase());
            taskLog.setInfo("Monitoring data uploaded");
        } catch (ClientProtocolException e) {
            throw new SearchLibException(e);
        } catch (IOException e) {
            throw new SearchLibException(e);
        } finally {
            ClientConnectionManager connectionManager = httpClient.getConnectionManager();
            if (connectionManager != null) connectionManager.shutdown();
        }
    }
public HttpURLConnection proxiedURLConnection(URL url, String serverName) throws IOException, PussycatException {
        if (this.httpProxy == null || this.httpProxy.equals("") || PussycatUtils.isLocalURL(url.toString()) || url.toString().contains(serverName)) {
            System.getProperties().put("proxySet", "false");
        } else {
            System.getProperties().put("proxySet", "true");
        }
        if (System.getProperties().getProperty("proxySet").equals("true")) {
            return (java.net.HttpURLConnection) url.openConnection(new java.net.Proxy(java.net.Proxy.Type.HTTP, new java.net.InetSocketAddress(this.httpProxy, this.httpProxyPort)));
        } else {
            return (java.net.HttpURLConnection) url.openConnection();
        }
    }
public static void main(String[] argv) {
        ComboPooledDataSource cpds = null;
        Connection c = null;
        try {
            cpds = new ComboPooledDataSource();
            cpds.setDriverClass("org.postgresql.Driver");
            cpds.setJdbcUrl("jdbc:postgresql://localhost/c3p0-test");
            cpds.setUser("swaldman");
            cpds.setPassword("test");
            cpds.setMinPoolSize(5);
            cpds.setAcquireIncrement(5);
            cpds.setMaxPoolSize(20);
            c = cpds.getConnection();
            c.setAutoCommit(false);
            Statement stmt = c.createStatement();
            stmt.executeUpdate("CREATE TABLE pwtest_table (col1 char(5), col2 char(5))");
            ResultSet rs = stmt.executeQuery("SELECT * FROM pwtest_table");
            System.err.println("rs: " + rs);
            System.err.println("rs.getStatement(): " + rs.getStatement());
            System.err.println("rs.getStatement().getConnection(): " + rs.getStatement().getConnection());
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (c != null) c.rollback();
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                if (cpds != null) cpds.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
public static void copyFolderStucture(String strPath, String dstPath) throws IOException {
        Constants.iLog.LogInfoLine("copying " + strPath);
        File src = new File(strPath);
        File dest = new File(dstPath);
        if (src.isDirectory()) {
            dest.mkdirs();
            String list[] = src.list();
            for (int i = 0; i < list.length; i++) {
                String dest1 = dest.getAbsolutePath() + "\\" + list[i];
                String src1 = src.getAbsolutePath() + "\\" + list[i];
                copyFolderStucture(src1, dest1);
            }
        } else {
            FileInputStream fin = new FileInputStream(src);
            FileOutputStream fout = new FileOutputStream(dest);
            int c;
            while ((c = fin.read()) >= 0) fout.write(c);
            fin.close();
            fout.close();
        }
    }
private void addDocToDB(String action, DataSource database) {
        String typeOfDoc = findTypeOfDoc(action).trim().toLowerCase();
        Connection con = null;
        try {
            con = database.getConnection();
            con.setAutoCommit(false);
            checkDupDoc(typeOfDoc, con);
            String add = "insert into " + typeOfDoc + " values( ?, ?, ?, ?, ?, ?, ? )";
            PreparedStatement prepStatement = con.prepareStatement(add);
            prepStatement.setString(1, selectedCourse.getCourseId());
            prepStatement.setString(2, selectedCourse.getAdmin());
            prepStatement.setTimestamp(3, getTimeStamp());
            prepStatement.setString(4, getLink());
            prepStatement.setString(5, homePage.getUser());
            prepStatement.setString(6, getText());
            prepStatement.setString(7, getTitle());
            prepStatement.executeUpdate();
            prepStatement.close();
            con.commit();
        } catch (Exception e) {
            sqlError = true;
            e.printStackTrace();
            if (con != null) try {
                con.rollback();
            } catch (Exception logOrIgnore) {
            }
            try {
                throw e;
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        } finally {
            if (con != null) try {
                con.close();
            } catch (Exception logOrIgnore) {
            }
        }
    }
public static int UsePassword(String username, String password, String new_password) {
        try {
            URL url = new URL("http://eiffel.itba.edu.ar/hci/service/Security.groovy?method=ChangePassword&username=" + username + "&password=" + password + "&new_password=" + new_password);
            URLConnection urlc = url.openConnection();
            urlc.setDoOutput(false);
            urlc.setAllowUserInteraction(false);
            BufferedReader br = new BufferedReader(new InputStreamReader(urlc.getInputStream()));
            String str;
            StringBuffer sb = new StringBuffer();
            while ((str = br.readLine()) != null) {
                sb.append(str);
                sb.append("\n");
            }
            br.close();
            String response = sb.toString();
            if (response == null) {
                return -1;
            }
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            InputSource is = new InputSource();
            is.setCharacterStream(new StringReader(response));
            Document dom = db.parse(is);
            NodeList nl = dom.getElementsByTagName("response");
            String status = ((Element) nl.item(0)).getAttributes().item(0).getTextContent();
            if (status.toString().equals("fail")) {
                return -1;
            }
            return 0;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return -1;
    }
private InputStream connectURL(String aurl) throws IOException {
        InputStream in = null;
        int response = -1;
        URL url = new URL(aurl);
        URLConnection conn = url.openConnection();
        if (!(conn instanceof HttpURLConnection)) throw new IOException("Not an HTTP connection.");
        HttpURLConnection httpConn = (HttpURLConnection) conn;
        response = getResponse(httpConn);
        if (response == HttpURLConnection.HTTP_OK) {
            in = httpConn.getInputStream();
        } else throw new IOException("Response Code: " + response);
        return in;
    }
public void test() {
        try {
            String query = "* <http://xmlns.com/foaf/0.1/workplaceHomepage> <http://www.deri.ie/>" + "* <http://xmlns.com/foaf/0.1/knows> *";
            String url = "http://sindice.com/api/v2/search?qt=advanced&q=" + URLEncoder.encode(query, "utf-8") + "&qt=advanced";
            URL urlObj = new URL(url);
            URLConnection con = urlObj.openConnection();
            if (con != null) {
                Model model = ModelFactory.createDefaultModel();
                model.read(con.getInputStream(), null);
            }
            System.out.println(url);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
public static void main(String[] args) throws IOException {
        long start = System.currentTimeMillis();
        FileResourceManager frm = CommonsTransactionContext.configure(new File("C:/tmp"));
        try {
            frm.start();
        } catch (ResourceManagerSystemException e) {
            throw new RuntimeException(e);
        }
        FileInputStream is = new FileInputStream("C:/Alfresco/WCM_Eval_Guide2.0.pdf");
        CommonsTransactionOutputStream os = new CommonsTransactionOutputStream(new Ownerr());
        IOUtils.copy(is, os);
        IOUtils.closeQuietly(is);
        IOUtils.closeQuietly(os);
        try {
            frm.stop(FileResourceManager.SHUTDOWN_MODE_NORMAL);
        } catch (ResourceManagerSystemException e) {
            throw new RuntimeException(e);
        }
        System.out.println(System.currentTimeMillis() - start);
    }
private void processar() {
        boolean bOK = false;
        String sSQL = "DELETE FROM FNSALDOLANCA WHERE CODEMP=? AND CODFILIAL=?";
        try {
            state("Excluindo base atual de saldos...");
            PreparedStatement ps = con.prepareStatement(sSQL);
            ps.setInt(1, Aplicativo.iCodEmp);
            ps.setInt(2, ListaCampos.getMasterFilial("FNSALDOLANCA"));
            ps.executeUpdate();
            ps.close();
            state("Base excluida...");
            bOK = true;
        } catch (SQLException err) {
            Funcoes.mensagemErro(this, "Erro ao excluir os saldos!\n" + err.getMessage(), true, con, err);
            err.printStackTrace();
        }
        if (bOK) {
            bOK = false;
            sSQL = "SELECT CODPLAN,DATASUBLANCA,SUM(VLRSUBLANCA) VLRSUBLANCA FROM " + "FNSUBLANCA WHERE CODEMP=? AND CODFILIAL=? GROUP BY CODPLAN,DATASUBLANCA " + "ORDER BY CODPLAN,DATASUBLANCA";
            try {
                state("Iniciando reconstru��o...");
                PreparedStatement ps = con.prepareStatement(sSQL);
                ps.setInt(1, Aplicativo.iCodEmp);
                ps.setInt(2, ListaCampos.getMasterFilial("FNLANCA"));
                ResultSet rs = ps.executeQuery();
                String sPlanAnt = "";
                double dSaldo = 0;
                bOK = true;
                int iFilialPlan = ListaCampos.getMasterFilial("FNPLANEJAMENTO");
                int iFilialSaldo = ListaCampos.getMasterFilial("FNSALDOLANCA");
                while (rs.next() && bOK) {
                    if ("1010100000004".equals(rs.getString("CodPlan"))) {
                        System.out.println("Debug");
                    }
                    if (sPlanAnt.equals(rs.getString("CodPlan"))) {
                        dSaldo += rs.getDouble("VLRSUBLANCA");
                    } else dSaldo = rs.getDouble("VLRSUBLANCA");
                    bOK = insereSaldo(iFilialSaldo, iFilialPlan, rs.getString("CodPlan"), rs.getDate("DataSubLanca"), dSaldo);
                    sPlanAnt = rs.getString("CodPlan");
                    if ("1010100000004".equals(sPlanAnt)) {
                        System.out.println("Debug");
                    }
                }
                ps.close();
                state("Aguardando grava��o final...");
            } catch (SQLException err) {
                bOK = false;
                Funcoes.mensagemErro(this, "Erro ao excluir os lan�amentos!\n" + err.getMessage(), true, con, err);
                err.printStackTrace();
            }
        }
        try {
            if (bOK) {
                con.commit();
                state("Registros processados com sucesso!");
            } else {
                state("Registros antigos restaurados!");
                con.rollback();
            }
        } catch (SQLException err) {
            Funcoes.mensagemErro(this, "Erro ao relizar precedimento!\n" + err.getMessage(), true, con, err);
            err.printStackTrace();
        }
        bRunProcesso = false;
        btProcessar.setEnabled(true);
    }
public static final InputStream getInputStream(final String location) {
        final File f = new File(location);
        if (f.exists()) {
            try {
                return new FileInputStream(f);
            } catch (final FileNotFoundException e) {
                throw new Error(e);
            }
        }
        URL url = Iotil.class.getClassLoader().getResource(location);
        try {
            if (url == null) {
                url = new URL(location);
            }
            return url.openStream();
        } catch (final IOException e) {
            throw new RuntimeException(e);
        }
    }
public void play(File file) {
        try {
            URL url = new URL("http://127.0.0.1:8081/play.html?type=4&file=" + file.getAbsolutePath() + "&name=toto");
            URLConnection connection = url.openConnection();
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String inputLine;
            while ((inputLine = in.readLine()) != null) System.out.println(inputLine);
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
private int[] sortNodesToGoal(Graph g, int parent, int goal) {
        float a, b;
        int tempI, tempR;
        float tempF;
        int len = g.nodeList[parent].edges.length;
        int[] nodes = new int[len];
        float[] dists = new float[len];
        int[] ref = new int[len];
        if (len == 0) return null;
        if (len == 1) {
            ref[0] = 0;
            return ref;
        }
        for (int i = 0; i < len; i++) {
            nodes[i] = g.getOtherNode(parent, g.nodeList[parent].edges[i]);
            a = g.nodeList[nodes[i]].x - g.nodeList[goal].x;
            b = g.nodeList[nodes[i]].y - g.nodeList[goal].y;
            dists[i] = (float) Math.sqrt(a * a + b * b);
            ref[i] = i;
        }
        for (int i = len - 1; i >= 0; i--) {
            for (int j = 0; j < i; j++) {
                if (dists[j] > dists[j + 1]) {
                    tempI = nodes[j];
                    nodes[j] = nodes[j + 1];
                    nodes[j + 1] = tempI;
                    tempF = dists[j];
                    dists[j] = dists[j + 1];
                    dists[j + 1] = tempF;
                    tempR = ref[j];
                    ref[j] = ref[j + 1];
                    ref[j + 1] = tempR;
                }
            }
        }
        return ref;
    }
public static void request() {
        try {
            URL url = new URL("http://www.nseindia.com/marketinfo/companyinfo/companysearch.jsp?cons=ghcl&section=7");
            URLConnection conn = url.openConnection();
            conn.setDoOutput(true);
            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            while ((line = rd.readLine()) != null) {
                System.out.println(line);
            }
            rd.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
private void copyFile(File srcFile, File destFile) throws IOException {
        if (!(srcFile.exists() && srcFile.isFile())) throw new IllegalArgumentException("Source file doesn't exist: " + srcFile.getAbsolutePath());
        if (destFile.exists() && destFile.isDirectory()) throw new IllegalArgumentException("Destination file is directory: " + destFile.getAbsolutePath());
        FileInputStream in = new FileInputStream(srcFile);
        FileOutputStream out = new FileOutputStream(destFile);
        byte[] buffer = new byte[4096];
        int no = 0;
        try {
            while ((no = in.read(buffer)) != -1) out.write(buffer, 0, no);
        } finally {
            in.close();
            out.close();
        }
    }
public InputStream getInputStream() throws TGBrowserException {
        try {
            if (!this.isFolder()) {
                URL url = new URL(this.url);
                InputStream stream = url.openStream();
                return stream;
            }
        } catch (Throwable throwable) {
            throw new TGBrowserException(throwable);
        }
        return null;
    }
@Test
    public void testXMLDBURLStreamHandler() {
        System.out.println("testXMLDBURLStreamHandler");
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        try {
            URL url = new URL(XMLDB_URL_1);
            InputStream is = url.openStream();
            copyDocument(is, baos);
            is.close();
        } catch (Exception ex) {
            ex.printStackTrace();
            LOG.error(ex);
            fail(ex.getMessage());
        }
    }