semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
private byte[] loadResourceFromCodeBase(String name) {
        byte[] bytecode;
        InputStream is = null;
        logger.debug("LoadResourceFromCodeBase()++");
        try {
            URL url = new URL(this._codeBase, name);
            int content_length = -1;
            URLConnection connection = url.openConnection();
            connection.setRequestProperty("user-agent", "Aglets/1.1");
            connection.setRequestProperty("agent-system", "aglets");
            connection.setRequestProperty("agent-language", "java");
            connection.setDoInput(true);
            connection.setUseCaches(false);
            connection.connect();
            is = connection.getInputStream();
            content_length = connection.getContentLength();
            if (content_length < 0) {
                content_length = is.available();
            }
            if (content_length == 0) {
                return null;
            }
            bytecode = new byte[content_length];
            int offset = 0;
            while (content_length > 0) {
                int read = is.read(bytecode, offset, content_length);
                offset += read;
                content_length -= read;
            }
            is.close();
        } catch (IOException ex) {
            logger.error("Error loading [" + name + "] resource from [" + this._codeBase + "]", ex);
            bytecode = null;
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (Exception ex) {
                    logger.error("Error closing.", ex);
                }
            }
        }
        logger.debug("LoadResourceFromCodeBase()--");
        return bytecode;
    }
public static BufferedReader getUserSolveStream(String name) throws IOException {
        BufferedReader in;
        try {
            URL url = new URL("http://www.spoj.pl/status/" + name.toLowerCase() + "/signedlist/");
            in = new BufferedReader(new InputStreamReader(url.openStream()));
        } catch (MalformedURLException e) {
            in = null;
            throw e;
        }
        return in;
    }
private static synchronized byte[] gerarHash(String frase) {
        try {
            MessageDigest md = MessageDigest.getInstance(algoritmo);
            md.update(frase.getBytes());
            return md.digest();
        } catch (NoSuchAlgorithmException e) {
            return null;
        }
    }
public static BufferedReader getUserInfoStream(String name) throws IOException {
        BufferedReader in;
        try {
            URL url = new URL("http://www.spoj.pl/users/" + name.toLowerCase() + "/");
            in = new BufferedReader(new InputStreamReader(url.openStream()));
        } catch (MalformedURLException e) {
            in = null;
            throw e;
        }
        return in;
    }
private synchronized Map load() {
        if (!mustReloadConfigurationFiles()) {
            return groups;
        }
        SAXParser saxParser = null;
        JSODefaultHandler saxHandler = new JSODefaultHandler();
        try {
            final Collection resourcesByOrigin = getConfigResources();
            final LinkedList resourcesList = new LinkedList();
            Iterator iOrigin = resourcesByOrigin.iterator();
            while (iOrigin.hasNext()) {
                Resource resource = (Resource) iOrigin.next();
                String origin = resource.getSource();
                if (origin.startsWith(LOCAL_CLASSPATH) || JarRestrictionManager.getInstance().isJarAllowed(origin)) {
                    LOG.debug("Adding " + CONFIGURATION_FILE_NAME + " from " + origin + ".");
                    resourcesList.addFirst(resource.getUrl());
                } else {
                    LOG.debug("Jar " + origin + " refused. See jso.allowedJar property in jso.properties file.");
                }
            }
            URL external = getExternalResource();
            if (external != null) {
                resourcesList.addFirst(external);
            }
            saxParser = SAXParserFactory.newInstance().newSAXParser();
            Iterator ite = resourcesList.iterator();
            while (ite.hasNext()) {
                final URL url = (URL) ite.next();
                LOG.debug("Parsing of file " + url.toString() + ".");
                InputStream input = null;
                try {
                    input = url.openStream();
                    saxParser.parse(input, saxHandler);
                } catch (SAXException e) {
                    LOG.error("Parsing of file " + url.toString() + " failed! Parsing still continues.", e);
                } catch (IOException e) {
                    LOG.error("Reading of file " + url.toString() + " failed! Parsing still continues.", e);
                } finally {
                    if (input != null) {
                        try {
                            input.close();
                        } catch (IOException e) {
                            LOG.error("Closing inputstream of file " + url.toString() + " failed! Parsing still continues.", e);
                        }
                    }
                }
            }
        } catch (SAXException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (ParserConfigurationException e) {
            throw new RuntimeException(e);
        }
        this.defaultLocation = (String) saxHandler.getDefaultValues().get("location");
        this.defaultTimestampPolicy = (String) saxHandler.getDefaultValues().get("timeStampPolicy");
        if (this.defaultTimestampPolicy == null) this.defaultTimestampPolicy = Group.TIMESTAMP_LOCAL;
        this.groups = saxHandler.getListGroups();
        return this.groups;
    }
@Override
    protected void writeSnapshot(final String message, final String details) {
        try {
            final URL url = proxyAddress == null ? new URL(url_spec) : new URL("http", proxyAddress, proxyPort, url_spec);
            LOG.info("connect to " + url);
            final URLConnection connection = url.openConnection();
            connection.setDoOutput(true);
            final HttpQueryWriter out = new HttpQueryWriter(connection.getOutputStream());
            out.addParameter("error", message);
            out.addParameter("trace", details);
            out.close();
            final InputStream in = connection.getInputStream();
            int c;
            final StringBuffer result = new StringBuffer();
            while ((c = in.read()) != -1) {
                result.append((char) c);
            }
            LOG.info(result);
            in.close();
        } catch (final UnknownHostException e) {
            LOG.info("could not find host (unknown host) to submit log to");
        } catch (final IOException e) {
            LOG.debug("i/o problem submitting log", e);
        }
    }
public void readFile(URL url) throws PedroException, IOException, ParserConfigurationException, SAXException {
        this.zipFileName = url.toString();
        URLConnection urlConnection = url.openConnection();
        InputStream inputStream = urlConnection.getInputStream();
        unzipNativeFormatFile(inputStream);
        parseAlertFiles();
        deleteAlertFiles();
    }
private HttpURLConnection getItemURLConnection(final String method, final String id, final byte[] data, final Map<String, List<String>> headers) throws IOException {
        if (m_bucket == null) {
            throw new IllegalArgumentException("bucket is not set");
        }
        final URL itemURL = new URL("http://" + m_host + "/" + m_bucket + "/" + id);
        final HttpURLConnection urlConn = (HttpURLConnection) itemURL.openConnection();
        urlConn.setRequestMethod(method);
        urlConn.setReadTimeout(READ_TIMEOUT);
        if (headers != null) {
            for (final Map.Entry<String, List<String>> me : headers.entrySet()) {
                for (final String v : me.getValue()) {
                    urlConn.setRequestProperty(me.getKey(), v);
                }
            }
        }
        addAuthorization(urlConn, method, data);
        return urlConn;
    }
public String getUniqueId() {
        String digest = "";
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            String timeVal = "" + (System.currentTimeMillis() + 1);
            String localHost = "";
            ;
            try {
                localHost = InetAddress.getLocalHost().toString();
            } catch (UnknownHostException e) {
            }
            String randVal = "" + new Random().nextInt();
            String val = timeVal + localHost + randVal;
            md.reset();
            md.update(val.getBytes());
            digest = toHexString(md.digest());
        } catch (NoSuchAlgorithmException e) {
        }
        return digest;
    }
private void updateHoraatendo(Integer codemp, Integer codfilial, Integer codatendo, String horaatendo, String horaatendofin) throws SQLException {
        StringBuilder sql = new StringBuilder();
        sql.append("update atatendimento set horaatendo=?, horaatendofin=? ");
        sql.append("where codemp=? and codfilial=? and codatendo=?");
        PreparedStatement ps = getConn().prepareStatement(sql.toString());
        ps.setTime(1, Funcoes.strTimeToSqlTime(horaatendo, false));
        ps.setTime(2, Funcoes.strTimeToSqlTime(horaatendofin, false));
        ps.setInt(3, codemp);
        ps.setInt(4, codfilial);
        ps.setInt(5, codatendo);
        ps.executeUpdate();
        ps.close();
        try {
            getConn().commit();
        } catch (SQLException e) {
            getConn().rollback();
        }
    }
public static void main(String[] args) {
        URL url = Thread.currentThread().getContextClassLoader().getResource("org/jeditor/resources/jeditor.properties");
        try {
            PropertyResourceBundle prb = new PropertyResourceBundle(url.openStream());
            String version = prb.getString("version");
            String date = prb.getString("date");
            System.out.println("jEditor version " + version + " build on " + date);
            System.out.println("Distributed under GPL license");
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
private void publishMap(LWMap map) throws IOException {
        File savedMap = PublishUtil.saveMap(map);
        InputStream istream = new BufferedInputStream(new FileInputStream(savedMap));
        OutputStream ostream = new BufferedOutputStream(new FileOutputStream(ActionUtil.selectFile("ConceptMap", "vue")));
        int fileLength = (int) savedMap.length();
        byte bytes[] = new byte[fileLength];
        while (istream.read(bytes, 0, fileLength) != -1) ostream.write(bytes, 0, fileLength);
        istream.close();
        ostream.close();
    }
private void publishCMap(LWMap map) throws IOException {
        try {
            File savedCMap = PublishUtil.createIMSCP(Publisher.resourceVector);
            InputStream istream = new BufferedInputStream(new FileInputStream(savedCMap));
            OutputStream ostream = new BufferedOutputStream(new FileOutputStream(ActionUtil.selectFile("IMSCP", "zip")));
            int fileLength = (int) savedCMap.length();
            byte bytes[] = new byte[fileLength];
            while (istream.read(bytes, 0, fileLength) != -1) ostream.write(bytes, 0, fileLength);
            istream.close();
            ostream.close();
        } catch (IOException ex) {
            throw ex;
        } catch (Exception ex) {
            System.out.println(ex);
            VueUtil.alert(VUE.getDialogParent(), VueResources.getString("dialog.export.message") + ex.getMessage(), VueResources.getString("dialog.export.title"), JOptionPane.ERROR_MESSAGE);
        }
    }
private void publishZip(LWMap map) {
        try {
            if (map.getFile() == null) {
                VueUtil.alert(VueResources.getString("dialog.mapsave.message"), VueResources.getString("dialog.mapsave.title"));
                return;
            }
            File savedCMap = PublishUtil.createZip(map, Publisher.resourceVector);
            InputStream istream = new BufferedInputStream(new FileInputStream(savedCMap));
            OutputStream ostream = new BufferedOutputStream(new FileOutputStream(ActionUtil.selectFile("Export to Zip File", "zip")));
            int fileLength = (int) savedCMap.length();
            byte bytes[] = new byte[fileLength];
            while (istream.read(bytes, 0, fileLength) != -1) ostream.write(bytes, 0, fileLength);
            istream.close();
            ostream.close();
        } catch (Exception ex) {
            System.out.println(ex);
            VueUtil.alert(VUE.getDialogParent(), VueResources.getString("dialog.export.message") + ex.getMessage(), VueResources.getString("dialog.export.title"), JOptionPane.ERROR_MESSAGE);
            ex.printStackTrace();
        }
    }
private FeedIF retrieveFeed(String uri) throws FeedManagerException {
        try {
            URL urlToRetrieve = new URL(uri);
            URLConnection conn = null;
            try {
                conn = urlToRetrieve.openConnection();
                if (conn instanceof HttpURLConnection) {
                    HttpURLConnection httpConn = (HttpURLConnection) conn;
                    httpConn.setInstanceFollowRedirects(true);
                    HttpHeaderUtils.setUserAgent(httpConn, "Informa Java API");
                    logger.debug("retr feed at url " + uri + ": ETag" + HttpHeaderUtils.getETagValue(httpConn) + " if-modified :" + HttpHeaderUtils.getLastModified(httpConn));
                    this.httpHeaders.setETag(HttpHeaderUtils.getETagValue(httpConn));
                    this.httpHeaders.setIfModifiedSince(HttpHeaderUtils.getLastModified(httpConn));
                }
            } catch (java.lang.ClassCastException e) {
                conn = null;
                logger.warn("problem cast to HttpURLConnection " + uri, e);
                throw new FeedManagerException(e);
            } catch (NullPointerException e) {
                logger.error("problem NPE " + uri + " conn=" + conn, e);
                conn = null;
                throw new FeedManagerException(e);
            }
            ChannelIF channel = null;
            channel = FeedParser.parse(getChannelBuilder(), conn.getInputStream());
            this.timeToExpire = getTimeToExpire(channel);
            this.feed = new Feed(channel);
            Date currDate = new Date();
            this.feed.setLastUpdated(currDate);
            this.feed.setDateFound(currDate);
            this.feed.setLocation(urlToRetrieve);
            logger.info("feed retrieved " + uri);
        } catch (IOException e) {
            logger.error("IOException " + feedUri + " e=" + e);
            e.printStackTrace();
            throw new FeedManagerException(e);
        } catch (ParseException e) {
            e.printStackTrace();
            throw new FeedManagerException(e);
        }
        return this.feed;
    }
protected Control createDialogArea(Composite parent) {
        Composite composite = (Composite) super.createDialogArea(parent);
        setTitle(DialogsMessages.getString("LicenseDialog.Caption"));
        setMessage(DialogsMessages.getString("LicenseDialog.Explanation"));
        Composite content = new Composite(composite, SWT.NONE);
        content.setLayoutData(new GridData(GridData.FILL_BOTH));
        final int ncol = 1;
        GridLayout layout = new GridLayout(1, false);
        layout.numColumns = ncol;
        content.setLayout(layout);
        Browser browser = null;
        Text text = null;
        try {
            browser = new Browser(content, SWT.NONE);
            browser.setLayoutData(new GridData(GridData.FILL_BOTH));
        } catch (Throwable t) {
            text = new Text(content, SWT.MULTI | SWT.WRAP | SWT.VERTICAL);
            text.setLayoutData(new GridData(GridData.FILL_BOTH));
        }
        URL url = PalobrowserPlugin.getDefault().getBundle().getResource(browser != null ? "license.html" : "license.txt");
        InputStream in = null;
        BufferedReader r = null;
        StringBuffer sb = new StringBuffer();
        try {
            in = url.openStream();
            r = new BufferedReader(new InputStreamReader(in, "ISO-8859-1"));
            String line;
            while ((line = r.readLine()) != null) sb.append(line).append("\r\n");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (r != null) {
                try {
                    r.close();
                } catch (IOException e) {
                }
            }
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                }
            }
        }
        if (browser != null) browser.setText(sb.toString()); else text.setText(sb.toString());
        return composite;
    }
@Override
    public synchronized HttpURLConnection getTileUrlConnection(int zoom, int tilex, int tiley) throws IOException {
        HttpURLConnection conn = null;
        try {
            String url = getTileUrl(zoom, tilex, tiley);
            conn = (HttpURLConnection) new URL(url).openConnection();
        } catch (IOException e) {
            throw e;
        } catch (Exception e) {
            log.error("", e);
            throw new IOException(e);
        }
        try {
            i.set("conn", conn);
            i.eval("addHeaders(conn);");
        } catch (EvalError e) {
            String msg = e.getMessage();
            if (!AH_ERROR.equals(msg)) {
                log.error(e.getClass() + ": " + e.getMessage(), e);
                throw new IOException(e);
            }
        }
        return conn;
    }
public static void main(String[] args) throws MalformedURLException, IOException {
        InputStream in = null;
        try {
            in = new URL("hdfs://localhost:8020/user/leeing/maxtemp/sample.txt").openStream();
            IOUtils.copyBytes(in, System.out, 8192, false);
        } finally {
            IOUtils.closeStream(in);
            System.out.println("\nend.");
        }
    }
public static Recipes addRecipe(Lists complexity, String about, String title, Users user, int preparationTime, int cookingTime, int servings, Lists dishType, String picUrl, Iterable<String> instructions) throws Exception {
        URL url = new URL(picUrl);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.connect();
        Recipes rec = new Recipes(user, title, about, preparationTime, cookingTime, servings, complexity, dishType, Hibernate.createBlob(conn.getInputStream(), conn.getContentLength()), new Date(), 0);
        session.save(rec);
        for (String s : instructions) {
            createRecipeInstructions(rec, s);
        }
        return rec;
    }
public SpreadSheetFrame(FileManager owner, File file, Delimiter delim) {
        super(owner, file.getPath());
        JPanel pane = new JPanel(new BorderLayout());
        super.contentPane.add(pane);
        this.tableModel = new BigTableModel(file, delim);
        this.table = new JTable(tableModel);
        this.table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
        this.tableModel.setTable(this.table);
        pane.add(new JScrollPane(this.table));
        addInternalFrameListener(new InternalFrameAdapter() {

            @Override
            public void internalFrameClosed(InternalFrameEvent e) {
                tableModel.close();
            }
        });
        JMenu menu = new JMenu("Tools");
        getJMenuBar().add(menu);
        menu.add(new AbstractAction("NCBI") {

            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    Pattern delim = Pattern.compile("[ ]");
                    BufferedReader r = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream("/home/lindenb/jeter.txt.gz"))));
                    String line = null;
                    URL url = new URL("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi");
                    URLConnection conn = url.openConnection();
                    conn.setDoOutput(true);
                    OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
                    wr.write("db=snp&retmode=xml");
                    while ((line = r.readLine()) != null) {
                        String tokens[] = delim.split(line, 2);
                        if (!tokens[0].startsWith("rs")) continue;
                        wr.write("&id=" + tokens[0].substring(2).trim());
                    }
                    wr.flush();
                    r.close();
                    InputStream in = conn.getInputStream();
                    IOUtils.copyTo(in, System.err);
                    in.close();
                    wr.close();
                } catch (IOException err) {
                    err.printStackTrace();
                }
            }
        });
    }
@Override
            public void actionPerformed(ActionEvent e) {
                try {
                    Pattern delim = Pattern.compile("[ ]");
                    BufferedReader r = new BufferedReader(new InputStreamReader(new GZIPInputStream(new FileInputStream("/home/lindenb/jeter.txt.gz"))));
                    String line = null;
                    URL url = new URL("http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi");
                    URLConnection conn = url.openConnection();
                    conn.setDoOutput(true);
                    OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
                    wr.write("db=snp&retmode=xml");
                    while ((line = r.readLine()) != null) {
                        String tokens[] = delim.split(line, 2);
                        if (!tokens[0].startsWith("rs")) continue;
                        wr.write("&id=" + tokens[0].substring(2).trim());
                    }
                    wr.flush();
                    r.close();
                    InputStream in = conn.getInputStream();
                    IOUtils.copyTo(in, System.err);
                    in.close();
                    wr.close();
                } catch (IOException err) {
                    err.printStackTrace();
                }
            }