semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
protected NetQuery(String serviceURL, String query, byte queryType, String defaultGraph, int timeout) {
        String urlString = null;
        try {
            queryString = query;
            char delim = serviceURL.indexOf('?') == -1 ? '?' : '&';
            if (queryType == Query.UPDATE_TYPE) urlString = serviceURL; else {
                urlString = serviceURL + delim + "query=" + URLEncoder.encode(query, "UTF-8");
                delim = '&';
                if (defaultGraph != null) urlString += delim + "default-graph-uri=" + defaultGraph;
            }
            URL url = new URL(urlString);
            conn = (HttpURLConnection) url.openConnection();
            configureConnection(query, queryType, timeout, defaultGraph);
        } catch (UnsupportedEncodingException e) {
            System.err.println(e.toString());
            e.printStackTrace();
            System.exit(-1);
        } catch (MalformedURLException e) {
            System.err.println(e.toString() + " for URL: " + urlString);
            System.err.println(serviceURL);
            e.printStackTrace();
            System.exit(-1);
        } catch (IOException e) {
            System.err.println(e.toString());
            e.printStackTrace();
            System.exit(-1);
        }
    }
private void weightAndPlaceClasses() {
        int rows = getRows();
        for (int curRow = _maxPackageRank; curRow < rows; curRow++) {
            xPos = getHGap() / 2;
            ClassdiagramNode[] rowObject = getObjectsInRow(curRow);
            for (int i = 0; i < rowObject.length; i++) {
                if (curRow == _maxPackageRank) {
                    int nDownlinks = rowObject[i].getDownlinks().size();
                    rowObject[i].setWeight((nDownlinks > 0) ? (1 / nDownlinks) : 2);
                } else {
                    Vector uplinks = rowObject[i].getUplinks();
                    int nUplinks = uplinks.size();
                    if (nUplinks > 0) {
                        float average_col = 0;
                        for (int j = 0; j < uplinks.size(); j++) {
                            average_col += ((ClassdiagramNode) (uplinks.elementAt(j))).getColumn();
                        }
                        average_col /= nUplinks;
                        rowObject[i].setWeight(average_col);
                    } else {
                        rowObject[i].setWeight(1000);
                    }
                }
            }
            int[] pos = new int[rowObject.length];
            for (int i = 0; i < pos.length; i++) {
                pos[i] = i;
            }
            boolean swapped = true;
            while (swapped) {
                swapped = false;
                for (int i = 0; i < pos.length - 1; i++) {
                    if (rowObject[pos[i]].getWeight() > rowObject[pos[i + 1]].getWeight()) {
                        int temp = pos[i];
                        pos[i] = pos[i + 1];
                        pos[i + 1] = temp;
                        swapped = true;
                    }
                }
            }
            for (int i = 0; i < pos.length; i++) {
                rowObject[pos[i]].setColumn(i);
                if ((i > _vMax) && (rowObject[pos[i]].getUplinks().size() == 0) && (rowObject[pos[i]].getDownlinks().size() == 0)) {
                    if (getColumns(rows - 1) > _vMax) {
                        rows++;
                    }
                    rowObject[pos[i]].setRank(rows - 1);
                } else {
                    rowObject[pos[i]].setLocation(new Point(xPos, yPos));
                    xPos += rowObject[pos[i]].getSize().getWidth() + getHGap();
                }
            }
            yPos += getRowHeight(curRow) + getVGap();
        }
    }
private String loadSchemas() {
        StringWriter writer = new StringWriter();
        try {
            IOUtils.copy(CoreOdfValidator.class.getResourceAsStream("schema_list.properties"), writer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return writer.toString();
    }
public static String[] retrieveFasta(String id) throws Exception {
        URL url = new URL("http://www.uniprot.org/uniprot/" + id + ".fasta");
        BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
        String header = reader.readLine();
        StringBuffer seq = new StringBuffer();
        String line = "";
        while ((line = reader.readLine()) != null) {
            seq.append(line);
        }
        reader.close();
        String[] first = header.split("OS=");
        return new String[] { id, first[0].split("\\s")[1], first[1].split("GN=")[0], seq.toString() };
    }
public static List<String> readListFile(URL url) {
        List<String> names = new ArrayList<String>();
        if (url != null) {
            InputStream in = null;
            try {
                in = url.openStream();
                BufferedReader reader = new BufferedReader(new InputStreamReader(in));
                String line = "";
                while ((line = reader.readLine()) != null) {
                    if (!line.startsWith("#")) {
                        names.add(line);
                    }
                }
            } catch (Exception e) {
                throw new RuntimeException(e);
            } finally {
                try {
                    if (in != null) in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
        return names;
    }
private void makeRequest(String data) {
        try {
            URL url = new java.net.URL(curLocation, this.url);
            if ("file".equals(url.getProtocol())) {
                if (PUT_METHOD.equals(method)) {
                    String text = "";
                    if (data != null) text = data.toString();
                    FileWriter out = new FileWriter(new java.io.File(new java.net.URI(url.toString())));
                    out.write(text, 0, text.length());
                    out.flush();
                    out.close();
                } else if (DELETE_METHOD.equals(method)) {
                    File file = new java.io.File(new java.net.URI(url.toString()));
                    file.delete();
                } else {
                    URLConnection connection = url.openConnection();
                    connection.connect();
                    handleResponse(connection);
                }
            } else {
                HttpURLConnection connection = (HttpURLConnection) url.openConnection();
                connection.setRequestMethod(method);
                for (Iterator iterator = headers.entrySet().iterator(); iterator.hasNext(); ) {
                    Map.Entry entry = (Map.Entry) iterator.next();
                    String property = (String) entry.getKey();
                    String value = (String) entry.getValue();
                    connection.addRequestProperty(property, value);
                }
                connection.connect();
                handleResponse(connection);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
public void doRender() throws IOException {
        File file = new File(fileName);
        if (!file.exists()) {
            logger.error("Static resource not found: " + fileName);
            isNotFound = true;
            return;
        }
        if (fileName.endsWith("xml") || fileName.endsWith("asp")) servletResponse.setContentType("text/xml"); else if (fileName.endsWith("css")) servletResponse.setContentType("text/css"); else if (fileName.endsWith("js")) servletResponse.setContentType("text/javascript");
        InputStream in = null;
        try {
            in = new FileInputStream(file);
            IOUtils.copy(in, servletResponse.getOutputStream());
            logger.debug("Static resource rendered: ".concat(fileName));
        } catch (FileNotFoundException e) {
            logger.error("Static resource not found: " + fileName);
            isNotFound = true;
        } finally {
            IOUtils.closeQuietly(in);
        }
    }
public static String ReadURLString(String str) throws IOException {
        try {
            URL url = new URL(str);
            InputStream is = url.openStream();
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader in = new BufferedReader(isr);
            String inputLine;
            String line = "";
            int i = 0;
            while ((inputLine = in.readLine()) != null) {
                line += inputLine + "\n";
            }
            is.close();
            isr.close();
            in.close();
            return line;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "";
    }
public static void main(String args[]) {
        try {
            URL url = new URL("http://dev.activeanalytics.ca/piwik.php?url=http%3a%2f%2flyricscatcher.sourceforge.net%2fpiwik.php&action_name=&idsite=1&res=1440x900&h=17&m=2&s=16&fla=1&dir=1&qt=1&realp=1&pdf=1&wma=1&java=1&cookie=0&title=JAVAACCESS&urlref=http%3a%2f%2flyricscatcher.sourceforge.net%2fcomputeraccespage.html");
            InputStream ist = url.openStream();
            InputStreamReader isr = new InputStreamReader(ist);
            BufferedReader in = new BufferedReader(isr);
            String line = "";
            String inputline = "";
            while ((inputline = in.readLine()) != null) {
                line += inputline + "\n";
            }
            System.out.println("finished: length=" + line.length() + "line=" + line);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            URL url = new URL("http://apps.sourceforge.net/piwik/lyricscatcher/piwik.php?url=http%3a%2f%2flyricscatcher.sourceforge.net%2fpiwik.php&action_name=&idsite=1&res=1440x900&h=0&m=22&s=1&fla=1&dir=1&qt=1&realp=1&pdf=1&wma=1&java=1&cookie=0&title=JAVAACCESS&urlref=http%3a%2f%2flyricscatcher.sourceforge.net%2fcomputeraccespage.html");
            InputStream ist = url.openStream();
            InputStreamReader isr = new InputStreamReader(ist);
            BufferedReader in = new BufferedReader(isr);
            String line = "";
            String inputline = "";
            while ((inputline = in.readLine()) != null) {
                line += inputline + "\n";
            }
            System.out.println("finished: length=" + line.length() + "line=" + line);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            URL url = new URL("http://apps.sourceforge.net/piwik/lyricscatcher/piwik.php?url=http%3A%2F%2Flyricscatcher.sourceforge.net%2Fcomputeracces.html&action_name=&idsite=1&res=1440x900&h=0&m=28&s=36&fla=1&dir=1&qt=1&realp=0&pdf=1&wma=1&java=1&cookie=1&title=&urlref=");
            InputStream ist = url.openStream();
            InputStreamReader isr = new InputStreamReader(ist);
            BufferedReader in = new BufferedReader(isr);
            String line = "";
            String inputline = "";
            while ((inputline = in.readLine()) != null) {
                line += inputline + "\n";
            }
            System.out.println("finished: length=" + line.length() + "line=" + line);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
public static void test() {
        addToCounter("computeracces.html");
        try {
            JFrame jfr = new JFrame("Webconnect");
            URL url = new URL("http://apps.sourceforge.net/piwik/lyricscatcher/piwik.php?idsite=1");
            JEditorPane jep = new JEditorPane();
            jfr.add(jep);
            String urlstr = "http://apps.sourceforge.net/piwik/lyricscatcher/piwik.php?url=http%3a%2f%2flyricscatcher.sourceforge.net%2fpiwik.php&action_name=&idsite=1&res=1440x900&h=";
            Calendar cal = Calendar.getInstance();
            urlstr += cal.get(Calendar.HOUR_OF_DAY);
            urlstr += "&m=";
            urlstr += cal.get(Calendar.MINUTE);
            urlstr += "&s=";
            urlstr += cal.get(Calendar.SECOND);
            urlstr += "&fla=1&dir=1&qt=1&realp=1&pdf=1&wma=1&java=1&cookie=0&title=JAVAACCESS&urlref=http%3a%2f%2flyricscatcher.sourceforge.net%2fcomputeraccespage.html";
            System.out.println(urlstr);
            URL nurl = new URL(urlstr);
            InputStream ist = nurl.openStream();
            InputStreamReader isr = new InputStreamReader(ist);
            BufferedReader in = new BufferedReader(isr);
            String line = "";
            String inputline = "";
            while ((inputline = in.readLine()) != null) {
                line += inputline + "\n";
            }
            System.out.println("finished: length of correct url=" + line.length());
            URL myurl = new URL(urlstr);
            URLConnection urlc = myurl.openConnection();
            urlc.getContent();
            System.out.println(urlc.getLastModified());
            System.out.println(urlc.getPermission());
            System.out.println(urlc.getRequestProperties());
            System.out.println(urlc.getContentEncoding());
            System.out.println(urlc.getContentLength());
            urlc.connect();
            InputStream dist = myurl.openStream();
            while (ist.available() >= 0) {
                ist.read();
            }
            ist.close();
            Document d = jep.getEditorKitForContentType("html").createDefaultDocument();
            d.getDefaultRootElement();
            jep.setContentType("text/html");
            jep.setText("<html><img src=\"http://apps.sourceforge.net/piwik/lyricscatcher/piwik.php?idsite=1\" alt=\"there's a problem...\"/><img src=\"" + urlstr + "\" alt=\"Another problem\" style=\"border:0\" /></html>");
            jfr.setLocationByPlatform(true);
            jfr.setSize(100, 100);
            jfr.show();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
public void getDownloadInfo(String _url) throws Exception {
        cl = new DefaultHttpClient();
        InfoAuthPromter hp = new InfoAuthPromter();
        cl.setCredentialsProvider(hp);
        head = new HttpHead(_url);
        head.setHeader("User-Agent", "test");
        head.setHeader("Accept", "*/*");
        head.setHeader("Range", "bytes=0-");
        HttpResponse resp = cl.execute(head);
        ent = resp.getEntity();
        int code = resp.getStatusLine().getStatusCode();
        if (code == 401) {
            throw new Exception("HTTP Auth Failed");
        }
        AuthManager.putAuth(getSite(), auth);
        setURL(head.getURI().toString());
        setSize(ent.getContentLength());
        setRangeEnd(getSize() - 1);
        setResumable(code == 206);
    }
public void movePrior(String[] showOrder, String[] orgID, String targetShowOrder, String targetOrgID) throws Exception {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet result = null;
        int moveCount = showOrder.length;
        DBOperation dbo = factory.createDBOperation(POOL_NAME);
        String strQuery = "select show_order from " + Common.ORGANIZE_TABLE + " where show_order=" + showOrder[moveCount - 1] + " and organize_id= '" + orgID[moveCount - 1] + "'";
        try {
            con = dbo.getConnection();
            con.setAutoCommit(false);
            ps = con.prepareStatement(strQuery);
            result = ps.executeQuery();
            int maxOrderNo = 0;
            if (result.next()) {
                maxOrderNo = result.getInt(1);
            }
            String[] sqls = new String[moveCount + 1];
            sqls[0] = "update " + Common.ORGANIZE_TABLE + " set show_order=" + maxOrderNo + " where show_order=" + targetShowOrder + " and organize_id= '" + targetOrgID + "'";
            for (int i = 0; i < showOrder.length; i++) {
                sqls[i + 1] = "update " + Common.ORGANIZE_TABLE + " set show_order=show_order-1" + " where show_order=" + showOrder[i] + " and organize_id= '" + orgID[i] + "'";
            }
            for (int j = 0; j < sqls.length; j++) {
                ps = con.prepareStatement(sqls[j]);
                int resultCount = ps.executeUpdate();
                if (resultCount != 1) {
                    throw new CesSystemException("Organize.movePrior(): ERROR Inserting data " + "in T_SYS_ORGANIZE update !! resultCount = " + resultCount);
                }
            }
            con.commit();
        } catch (SQLException se) {
            if (con != null) {
                con.rollback();
            }
            throw new CesSystemException("Organize.movePrior(): SQLException while mov organize order " + " :\n\t" + se);
        } finally {
            con.setAutoCommit(true);
            close(dbo, ps, result);
        }
    }
public void moveNext(String[] showOrder, String[] orgID, String targetShowOrder, String targetOrgID) throws Exception {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet result = null;
        int moveCount = showOrder.length;
        DBOperation dbo = factory.createDBOperation(POOL_NAME);
        String strQuery = "select show_order from " + Common.ORGANIZE_TABLE + " where show_order=" + showOrder[0] + " and organize_id= '" + orgID[0] + "'";
        try {
            con = dbo.getConnection();
            con.setAutoCommit(false);
            ps = con.prepareStatement(strQuery);
            result = ps.executeQuery();
            int minOrderNo = 0;
            if (result.next()) {
                minOrderNo = result.getInt(1);
            }
            String[] sqls = new String[moveCount + 1];
            sqls[0] = "update " + Common.ORGANIZE_TABLE + " set show_order=" + minOrderNo + " where show_order=" + targetShowOrder + " and organize_id= '" + targetOrgID + "'";
            for (int i = 0; i < showOrder.length; i++) {
                sqls[i + 1] = "update " + Common.ORGANIZE_TABLE + " set show_order=show_order+1" + " where show_order=" + showOrder[i] + " and organize_id= '" + orgID[i] + "'";
            }
            for (int j = 0; j < sqls.length; j++) {
                ps = con.prepareStatement(sqls[j]);
                int resultCount = ps.executeUpdate();
                if (resultCount != 1) {
                    throw new CesSystemException("Organize.moveNext(): ERROR Inserting data " + "in T_SYS_ORGANIZE update !! resultCount = " + resultCount);
                }
            }
            con.commit();
        } catch (SQLException se) {
            if (con != null) {
                con.rollback();
            }
            throw new CesSystemException("Organize.moveNext(): SQLException while mov organize order " + " :\n\t" + se);
        } finally {
            con.setAutoCommit(true);
            close(dbo, ps, result);
        }
    }
public static Properties addAttributes(Node node, String[] names, Properties props, LogEvent evt) throws ConfigurationException {
        if (props == null) props = new Properties();
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            for (int i = 0; i < names.length; i++) {
                String value = addProperty(names[i], props, node, evt);
                if (value != null) {
                    md.update(names[i].getBytes());
                    md.update(value.getBytes());
                }
            }
            byte[] digest = md.digest();
            evt.addMessage("digest " + ISOUtil.hexString(digest));
            props.put(DIGEST_PROPERTY, digest);
        } catch (NoSuchAlgorithmException e) {
            throw new ConfigurationException(e);
        }
        return props;
    }
public static String getWebPage(URL urlObj) {
        try {
            String content = "";
            InputStreamReader is = new InputStreamReader(urlObj.openStream());
            BufferedReader reader = new BufferedReader(is);
            String line;
            while ((line = reader.readLine()) != null) {
                content += line;
            }
            return content;
        } catch (IOException e) {
            throw new Error("The page " + dbg.quote(urlObj.toString()) + "could not be retrieved." + "\nThis is could be caused by a number of things:" + "\n" + "\n  - the computer hosting the web page you want is down, or has returned an error" + "\n  - your computer does not have Internet access" + "\n  - the heat death of the universe has occurred, taking down all web servers with it");
        }
    }
private void loadMtlFile(URL url) throws IOException {
        InputStream is = url.openStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        int linecounter = 0;
        String[] params = null;
        try {
            String line;
            Material mtl = null;
            while (((line = br.readLine()) != null)) {
                linecounter++;
                line = line.trim();
                if ((line.length() == 0) || (line.startsWith("#"))) continue;
                params = line.split("\\s+");
                if (params[0].equals("newmtl")) {
                    mtl = new Material();
                    mtl.name = params[1];
                    materials.put(mtl.name, mtl);
                } else if (params[0].equals("map_Kd")) {
                    mtl.map_Kd = params[1];
                } else if (params[0].equals("Ka")) {
                    Arrays.fill(mtl.Ka, 0.0f);
                    for (int i = 1; i < params.length; i++) {
                        mtl.Ka[i - 1] = Float.valueOf(params[i]).floatValue();
                    }
                } else if (params[0].equals("Kd")) {
                    Arrays.fill(mtl.Kd, 0.0f);
                    for (int i = 1; i < params.length; i++) {
                        mtl.Kd[i - 1] = Float.valueOf(params[i]).floatValue();
                    }
                } else if (params[0].equals("Ks")) {
                    Arrays.fill(mtl.Ks, 0.0f);
                    for (int i = 1; i < params.length; i++) {
                        mtl.Ks[i - 1] = Float.valueOf(params[i]).floatValue();
                    }
                } else if (params[0].equals("d")) {
                    mtl.d = Float.valueOf(params[1]).floatValue();
                } else if (params[0].equals("Ns")) {
                    mtl.Ns = Float.valueOf(params[1]).floatValue();
                } else if (params[0].equals("illum")) {
                    mtl.illum = Integer.valueOf(params[1]).intValue();
                }
            }
        } catch (IOException e) {
            System.out.println("Failed to read file: " + br.toString());
        } catch (NumberFormatException e) {
            System.out.println("Malformed MTL (on line " + linecounter + "): " + br.toString() + "\r \r" + e.getMessage());
        }
    }