semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
private String getXml(String url) throws Exception {
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet(url);
        HttpResponse response = httpclient.execute(httpget);
        HttpEntity entity = response.getEntity();
        String results = null;
        if (entity != null) {
            long len = entity.getContentLength();
            if (len != -1 && len < 2048) {
                results = EntityUtils.toString(entity);
            } else {
            }
        }
        return (results);
    }
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
        try {
            String req1xml = jTextArea1.getText();
            java.net.URL url = new java.net.URL("http://217.34.8.235:8080/newgenlibctxt/PatronServlet");
            java.net.URLConnection urlconn = (java.net.URLConnection) url.openConnection();
            urlconn.setDoOutput(true);
            urlconn.setRequestProperty("Content-type", "text/xml; charset=UTF-8");
            java.io.OutputStream os = urlconn.getOutputStream();
            java.util.zip.CheckedOutputStream cos = new java.util.zip.CheckedOutputStream(os, new java.util.zip.Adler32());
            java.util.zip.GZIPOutputStream gop = new java.util.zip.GZIPOutputStream(cos);
            java.io.OutputStreamWriter dos = new java.io.OutputStreamWriter(gop, "UTF-8");
            System.out.println(req1xml);
            try {
                java.io.FileOutputStream pw = new java.io.FileOutputStream("C:/log.txt");
                pw.write(req1xml.getBytes());
                pw.flush();
                pw.close();
            } catch (Exception exp) {
                exp.printStackTrace();
            }
            dos.write(req1xml);
            dos.flush();
            dos.close();
            System.out.println("url conn: " + urlconn.getContentEncoding() + "  " + urlconn.getContentType());
            java.io.InputStream ios = urlconn.getInputStream();
            java.util.zip.CheckedInputStream cis = new java.util.zip.CheckedInputStream(ios, new java.util.zip.Adler32());
            java.util.zip.GZIPInputStream gip = new java.util.zip.GZIPInputStream(cis);
            java.io.BufferedReader br = new java.io.BufferedReader(new java.io.InputStreamReader(gip));
            String reqxml = "";
            while (br.ready()) {
                String line = br.readLine();
                reqxml += line;
            }
            try {
                java.io.FileOutputStream pw = new java.io.FileOutputStream("C:/log3.txt");
                pw.write(reqxml.getBytes());
                pw.flush();
                pw.close();
            } catch (Exception exp) {
                exp.printStackTrace();
            }
        } catch (Exception exp) {
            exp.printStackTrace();
        }
    }
private static String getData(String myurl) throws Exception {
        System.out.println("getdata");
        URL url = new URL(myurl);
        uc = (HttpURLConnection) url.openConnection();
        br = new BufferedReader(new InputStreamReader(uc.getInputStream()));
        String temp = "", k = "";
        while ((temp = br.readLine()) != null) {
            System.out.println(temp);
            k += temp;
        }
        br.close();
        return k;
    }
public static final String getHash(int iterationNb, String password, String salt) {
        try {
            MessageDigest digest = MessageDigest.getInstance("SHA-1");
            digest.reset();
            digest.update(salt.getBytes("UTF-8"));
            byte[] input = digest.digest(password.getBytes("UTF-8"));
            for (int i = 0; i < iterationNb; i++) {
                digest.reset();
                input = digest.digest(input);
            }
            String hashedValue = encoder.encode(input);
            LOG.finer("Creating hash '" + hashedValue + "' with iterationNb '" + iterationNb + "' and password '" + password + "' and salt '" + salt + "'!!");
            return hashedValue;
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException("Problem in the getHash method.", ex);
        }
    }
public void onUploadClicked(Event event) {
        Media[] medias = null;
        try {
            medias = Fileupload.get("Select one or more files to upload to " + "the current directory.", "Upload Files", 5);
        } catch (Exception e) {
            log.error("An exception occurred when displaying the file " + "upload dialog", e);
        }
        if (medias == null) {
            return;
        }
        for (Media media : medias) {
            String name = media.getName();
            CSPath potentialFile = model.getPathForFile(name);
            if (media.isBinary()) {
                CSPathOutputStream writer = null;
                try {
                    potentialFile.createNewFile();
                    if (potentialFile.exists()) {
                        writer = new CSPathOutputStream(potentialFile);
                        IOUtils.copy(media.getStreamData(), writer);
                    }
                } catch (IOException e) {
                    displayError("An error occurred when uploading the file " + name + ": " + e.getMessage());
                } finally {
                    if (writer != null) {
                        try {
                            writer.close();
                        } catch (IOException e) {
                        }
                    }
                }
            } else {
                CSPathWriter writer = null;
                try {
                    potentialFile.createNewFile();
                    if (potentialFile.exists()) {
                        writer = new CSPathWriter(potentialFile);
                        IOUtils.write(media.getStringData(), writer);
                    }
                } catch (IOException e) {
                    displayError("An error occurred when uploading the file " + name + ": " + e.getMessage());
                } finally {
                    if (writer != null) {
                        try {
                            writer.close();
                        } catch (IOException e) {
                        }
                    }
                }
            }
            model.fileCleanup(potentialFile);
            updateFileGrid();
        }
    }
private static Manifest getManifest() throws IOException {
        Stack manifests = new Stack();
        for (Enumeration e = Run.class.getClassLoader().getResources(MANIFEST); e.hasMoreElements(); ) manifests.add(e.nextElement());
        while (!manifests.isEmpty()) {
            URL url = (URL) manifests.pop();
            InputStream in = url.openStream();
            Manifest mf = new Manifest(in);
            in.close();
            if (mf.getMainAttributes().getValue(MAIN_CLASS) != null) return mf;
        }
        throw new Error("No " + MANIFEST + " with " + MAIN_CLASS + " found");
    }
public void initURL(URL url, boolean cache) throws IOException {
        this.url = url;
        if (cache) {
            System.out.println(getClass().getName() + ": caching '" + url + "'");
            InputStream urlIS = new BufferedInputStream(url.openStream(), 1024 * 30);
            file = File.createTempFile("_dss_", "_dss_");
            file.deleteOnExit();
            OutputStream cachedOS = new BufferedOutputStream(new FileOutputStream(file), 1024 * 30);
            byte[] buf = new byte[1024 * 4];
            long cachedBytesCount = 0;
            int count = 0;
            while ((count = urlIS.read(buf)) > 0) {
                cachedOS.write(buf, 0, count);
                cachedBytesCount += count;
            }
            urlIS.close();
            cachedOS.flush();
            cachedOS.close();
            this.cached = true;
            System.out.println(getClass().getName() + ": cached " + cachedBytesCount + " bytes into '" + file.getAbsolutePath() + "'");
        }
    }
public InputStream getInputStream(long offset) throws IOException {
        if (is != null && raf == null) {
            try {
                is.close();
            } catch (Throwable th) {
            } finally {
                is = null;
            }
        }
        if (is == null && getUrl() != null && getFile() == null) {
            is = url.openStream();
        }
        if (is == null) {
            if (getFile() != null) {
                raf = null;
                try {
                    raf = new RandomAccessFile(getFile(), "r");
                } catch (Exception ex) {
                }
                is = (raf != null) ? new RAFInputStream(raf, 0) : new BufferedInputStream(new FileInputStream(getFile()), 1024 * 30);
            }
        }
        if (is instanceof RAFInputStream) {
            RAFInputStream ris = (RAFInputStream) is;
            ris.seek(offset);
        } else {
            is.skip(offset);
        }
        return is;
    }
public byte[] applyTransformationOnURL(String url, int format) throws RemoteException {
        byte[] result = null;
        try {
            result = applyTransformation(new URL(url).openStream(), format);
        } catch (Exception e) {
            throwServiceException(e);
        }
        return result;
    }
public void run() {
        URL url;
        try {
            url = new URL("http://localhost:8080/glowaxes/dailytrend.jsp");
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            while ((str = in.readLine()) != null) {
            }
            in.close();
        } catch (MalformedURLException e) {
        } catch (IOException e) {
        }
    }
public static String getHash(String userName, String pass) {
        String hash = null;
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(userName.getBytes());
            hash = ISOUtil.hexString(md.digest(pass.getBytes())).toLowerCase();
        } catch (NoSuchAlgorithmException e) {
        }
        return hash;
    }
public void executeAction(JobContext context) throws Exception {
        HttpClient httpClient = (HttpClient) context.resolve("httpClient");
        List<NameValuePair> qparams = new ArrayList<NameValuePair>();
        Iterator<String> keySet = params.keySet().iterator();
        while (keySet.hasNext()) {
            String key = keySet.next();
            String value = params.get(key);
            qparams.add(new BasicNameValuePair(key, value));
        }
        String paramString = URLEncodedUtils.format(qparams, "UTF-8");
        if (this.url.endsWith("/")) {
            this.url = this.url.substring(0, this.url.length() - 1);
        }
        String url = this.url + paramString;
        URI uri = URI.create(url);
        HttpGet httpget = new HttpGet(uri);
        if (!(this.referer == null || this.referer.equals(""))) httpget.setHeader(this.referer, url);
        HttpResponse response = httpClient.execute(httpget);
        HttpEntity entity = response.getEntity();
        String content = "";
        if (entity != null) {
            content = EntityUtils.toString(entity, "UTF-8");
        }
    }
public void display(WebPage page, HttpServletRequest req, HttpServletResponse resp) throws DisplayException {
        page.getDisplayInitialiser().initDisplay(new HttpRequestDisplayContext(req), req);
        StreamProvider is = (StreamProvider) req.getAttribute(INPUTSTREAM_KEY);
        if (is == null) {
            throw new IllegalStateException("No OutputStreamDisplayHandlerXML.InputStream found in request attribute" + " OutputStreamDisplayHandlerXML.INPUTSTREAM_KEY");
        }
        resp.setContentType(is.getMimeType());
        resp.setHeader("Content-Disposition", "attachment;filename=" + is.getName());
        try {
            InputStream in = is.getInputStream();
            OutputStream out = resp.getOutputStream();
            if (in != null) {
                IOUtils.copy(in, out);
            }
            is.write(resp.getOutputStream());
            resp.flushBuffer();
        } catch (IOException e) {
            throw new DisplayException("Error writing input stream to response", e);
        }
    }
public void actionPerformed(ActionEvent e) {
        String digest = null;
        try {
            MessageDigest m = MessageDigest.getInstance("sha1");
            m.reset();
            String pw = String.copyValueOf(this.login.getPassword());
            m.update(pw.getBytes());
            byte[] digestByte = m.digest();
            BigInteger bi = new BigInteger(digestByte);
            digest = bi.toString();
            System.out.println(digest);
        } catch (NoSuchAlgorithmException e1) {
            e1.printStackTrace();
        }
        this.model.login(this.login.getHost(), this.login.getPort(), this.login.getUser(), digest);
    }
public static String getMdPsw(String passwd) throws Exception {
        MessageDigest md;
        md = MessageDigest.getInstance("MD5");
        byte[] md5hash = new byte[32];
        md.update(passwd.getBytes("iso-8859-1"), 0, passwd.length());
        md5hash = md.digest();
        return convertToHex(md5hash);
    }
public static String getFileContents(String path) {
        BufferedReader buffReader = null;
        if (path.indexOf("://") != -1) {
            URL url = null;
            try {
                url = new URL(path);
            } catch (MalformedURLException e) {
                logger.warn("Malformed URL: \"" + path + "\"");
            }
            try {
                String encoding = XMLKit.getDeclaredXMLEncoding(url.openStream());
                buffReader = new BufferedReader(new InputStreamReader(url.openStream(), encoding));
            } catch (IOException e) {
                logger.warn("I/O error trying to read \"" + path + "\"");
            }
        } else {
            File toRead = null;
            try {
                toRead = getExistingFile(path);
            } catch (FileNotFoundException e) {
                throw new UserError(new FileNotFoundException(path));
            }
            if (toRead.isAbsolute()) {
                String parent = toRead.getParent();
                try {
                    workingDirectory.push(URLTools.createValidURL(parent));
                } catch (FileNotFoundException e) {
                    throw new DeveloperError("Created an invalid parent file: \"" + parent + "\".", e);
                }
            }
            if (toRead.exists() && !toRead.isDirectory()) {
                path = toRead.getAbsolutePath();
                try {
                    String encoding = XMLKit.getDeclaredXMLEncoding(new FileInputStream(path));
                    buffReader = new BufferedReader(new InputStreamReader(new FileInputStream(path), encoding));
                } catch (IOException e) {
                    logger.warn("I/O error trying to read \"" + path + "\"");
                    return null;
                }
            } else {
                assert toRead.exists() : "getExistingFile() returned a non-existent file";
                if (toRead.isDirectory()) {
                    throw new UserError(new FileAlreadyExistsAsDirectoryException(toRead));
                }
            }
        }
        StringBuilder result = new StringBuilder();
        String line;
        try {
            while ((line = buffReader.readLine()) != null) {
                result.append(line);
            }
            buffReader.close();
        } catch (IOException e) {
            logger.warn("I/O error trying to read \"" + path + "\"");
            return null;
        }
        return result.toString();
    }
@Override
    public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException {
        String context = request.getContextPath();
        String resource = request.getRequestURI().replace(context, "");
        resource = resource.replaceAll("^/\\w*/", "");
        if ((StringUtils.isEmpty(resource)) || (resource.endsWith("/"))) {
            response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
            return;
        }
        URL url = ClassLoaderUtils.getResource(resource);
        if (url == null) {
            response.setStatus(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
        if ((this.deny != null) && (this.deny.length > 0)) {
            for (String s : this.deny) {
                s = s.trim();
                if (s.indexOf('*') != -1) {
                    s = s.replaceAll("\\*", ".*");
                }
                if (Pattern.matches(s, resource)) {
                    response.setStatus(HttpServletResponse.SC_FORBIDDEN);
                    return;
                }
            }
        }
        InputStream input = url.openStream();
        OutputStream output = response.getOutputStream();
        URLConnection connection = url.openConnection();
        String contentEncoding = connection.getContentEncoding();
        int contentLength = connection.getContentLength();
        String contentType = connection.getContentType();
        if (contentEncoding != null) {
            response.setCharacterEncoding(contentEncoding);
        }
        response.setContentLength(contentLength);
        response.setContentType(contentType);
        IOUtils.copy(input, output, true);
    }
private Object query(String json) throws IOException, ParseException {
        String envelope = "{\"qname1\":{\"query\":" + json + "}}";
        String urlStr = MQLREADURL + "?queries=" + URLEncoder.encode(envelope, "UTF-8");
        if (isDebugging()) {
            if (echoRequest) System.err.println("Sending:" + envelope);
        }
        URL url = new URL(urlStr);
        URLConnection con = url.openConnection();
        con.setRequestProperty("Cookie", COOKIE + "=" + "\"" + getMetawebCookie() + "\"");
        con.connect();
        InputStream in = con.getInputStream();
        Object item = new JSONParser(echoRequest ? new EchoReader(in) : in).object();
        in.close();
        String code = getString(item, "code");
        if (!"/api/status/ok".equals(code)) {
            throw new IOException("Bad code " + item);
        }
        code = getString(item, "qname1.code");
        if (!"/api/status/ok".equals(code)) {
            throw new IOException("Bad code " + item);
        }
        return item;
    }
public void importCertFile(File file) throws IOException {
        File kd;
        File cd;
        synchronized (this) {
            kd = keysDir;
            cd = certsDir;
        }
        if (!cd.isDirectory()) {
            kd.mkdirs();
            cd.mkdirs();
        }
        String newName = file.getName();
        File dest = new File(cd, newName);
        FileChannel sourceChannel = null;
        FileChannel destinationChannel = null;
        try {
            sourceChannel = new FileInputStream(file).getChannel();
            destinationChannel = new FileOutputStream(dest).getChannel();
            sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
        } finally {
            if (sourceChannel != null) {
                try {
                    sourceChannel.close();
                } catch (IOException e) {
                }
            }
            if (destinationChannel != null) {
                try {
                    destinationChannel.close();
                } catch (IOException e) {
                }
            }
        }
    }
public static String getHtml(DefaultHttpClient httpclient, String url, String encode) throws IOException {
        InputStream input = null;
        HttpGet get = new HttpGet(url);
        HttpResponse res = httpclient.execute(get);
        StatusLine status = res.getStatusLine();
        if (status.getStatusCode() != STATUSCODE_200) {
            throw new RuntimeException("50001");
        }
        if (res.getEntity() == null) {
            return "";
        }
        input = res.getEntity().getContent();
        InputStreamReader reader = new InputStreamReader(input, encode);
        BufferedReader bufReader = new BufferedReader(reader);
        String tmp = null, html = "";
        while ((tmp = bufReader.readLine()) != null) {
            html += tmp;
        }
        if (input != null) {
            input.close();
        }
        return html;
    }
public void fileCopy(File inFile, File outFile) {
        try {
            FileInputStream in = new FileInputStream(inFile);
            FileOutputStream out = new FileOutputStream(outFile);
            int c;
            while ((c = in.read()) != -1) out.write(c);
            in.close();
            out.close();
        } catch (IOException e) {
            System.err.println("Hubo un error de entrada/salida!!!");
        }
    }
public void fileCopy2(File inFile, File outFile) throws Exception {
        try {
            FileChannel srcChannel = new FileInputStream(inFile).getChannel();
            FileChannel dstChannel = new FileOutputStream(outFile).getChannel();
            dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
            srcChannel.close();
            dstChannel.close();
        } catch (IOException e) {
            throw new Exception("Could not copy file: " + inFile.getName());
        }
    }
@Test
    public void testEmptyValue() throws Exception {
        System.out.println("Test Empty Value...");
        EProperties props = new EProperties();
        URL url = this.getClass().getResource("emptyval.properties");
        System.out.println("Properties URL " + url);
        System.out.println("******************  LOADING URL  *************************");
        props.load(url);
        System.out.println("---list---");
        System.out.println(props.list());
        System.out.println("---list---");
        System.out.println("******************  LOADING Reader  *************************");
        EProperties p2 = new EProperties();
        p2.load(new InputStreamReader(url.openStream()));
        System.out.println("---list---");
        System.out.println(p2.list());
        System.out.println("---list---");
    }
public byte[] loadResource(String name) throws IOException {
        ClassPathResource cpr = new ClassPathResource(name);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        IOUtils.copy(cpr.getInputStream(), baos);
        return baos.toByteArray();
    }