semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public void run() {
                waiting(200);
                try {
                    URL url = new URL(urlAddress);
                    SAXParserFactory spf = SAXParserFactory.newInstance();
                    SAXParser sp = spf.newSAXParser();
                    XMLReader xr = sp.getXMLReader();
                    XMLHandlerSingleAlbum myXMLHandler = new XMLHandlerSingleAlbum();
                    xr.setContentHandler(myXMLHandler);
                    xr.parse(new InputSource(url.openStream()));
                    statuscode = myXMLHandler.statuscode;
                    if (statuscode != 200 && statuscode != 206) {
                        throw new Exception();
                    }
                    genre = myXMLHandler.genre;
                    genreId = myXMLHandler.genreId;
                    labelId = myXMLHandler.labelId;
                    label = myXMLHandler.label;
                    date = myXMLHandler.releaseDate;
                    rating = myXMLHandler.rating;
                    imageURL = myXMLHandler.imageURL;
                    artist = myXMLHandler.artist;
                    artistId = myXMLHandler.artistId;
                    numberOfTracks = myXMLHandler.nItems;
                    trackNames = myXMLHandler.tracks;
                    handlerSetContent.sendEmptyMessage(0);
                    dialog.dismiss();
                    updateImage();
                } catch (Exception e) {
                    final Exception ef = e;
                    nameTextView.post(new Runnable() {

                        public void run() {
                            nameTextView.setText(R.string.couldnt_get_album_info);
                        }
                    });
                }
                if (dialog.isShowing()) {
                    dialog.dismiss();
                }
                handlerDoneLoading.sendEmptyMessage(0);
            }
public static void main(String[] args) {
        FileDialog fd = new FileDialog(new Frame(), "Find a .def file", FileDialog.LOAD);
        boolean proceed = true;
        String input = "";
        DataInputStream dis;
        OutputStream out;
        InputStream in;
        File out_file, in_file;
        byte[] buffer = new byte[2048];
        int bytes_read;
        while (proceed) {
            fd.show();
            if (fd.getFile() != null) {
                try {
                    in_file = new File(fd.getDirectory(), fd.getFile());
                    out_file = new File(fd.getDirectory(), fd.getFile() + ".out");
                    out = new FileOutputStream(out_file);
                    in = new MSZipInputStream(new FileInputStream(in_file));
                    while ((bytes_read = in.read(buffer)) != -1) out.write(buffer, 0, bytes_read);
                    in.close();
                    out.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("Do another (y/n)?");
            dis = new DataInputStream(System.in);
            try {
                input = dis.readLine();
            } catch (Exception blah) {
            }
            if (input.toLowerCase().startsWith("n")) proceed = false;
        }
    }
public static String criptografar(String senha) {
        if (senha == null) {
            return null;
        }
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.update(senha.getBytes());
            BASE64Encoder encoder = new BASE64Encoder();
            return encoder.encode(digest.digest());
        } catch (NoSuchAlgorithmException ns) {
            LoggerFactory.getLogger(UtilAdrs.class).error(Msg.EXCEPTION_MESSAGE, UtilAdrs.class.getSimpleName(), ns);
            return senha;
        }
    }
public static String novoMetodoDeCriptografarParaMD5QueNaoFoiUtilizadoAinda(String input) {
        if (input == null) {
            return null;
        }
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.update(input.getBytes("UTF-8"));
            BigInteger hash = new BigInteger(1, digest.digest());
            String output = hash.toString(16);
            if (output.length() < 32) {
                int sizeDiff = 32 - output.length();
                do {
                    output = "0" + output;
                } while (--sizeDiff > 0);
            }
            return output;
        } catch (NoSuchAlgorithmException ns) {
            LoggerFactory.getLogger(UtilAdrs.class).error(Msg.EXCEPTION_MESSAGE, UtilAdrs.class.getSimpleName(), ns);
            return input;
        } catch (UnsupportedEncodingException e) {
            LoggerFactory.getLogger(UtilAdrs.class).error(Msg.EXCEPTION_MESSAGE, UtilAdrs.class.getSimpleName(), e);
            return input;
        }
    }
void readData() {
        String[] nextLine;
        int line;
        double value;
        URL url = null;
        String FileToRead;
        try {
            for (int i = 0; i < names.length; i++) {
                FileToRead = "data/" + names[i] + ".csv";
                url = new URL(ja.getCodeBase(), FileToRead);
                System.out.println(url.toString());
                InputStream in = url.openStream();
                CSVReader reader = new CSVReader(new InputStreamReader(in));
                line = 0;
                while ((nextLine = reader.readNext()) != null) {
                    allset.months[line] = Integer.parseInt(nextLine[0].substring(0, 2));
                    allset.years[line] = Integer.parseInt(nextLine[0].substring(6, 10));
                    value = Double.parseDouble(nextLine[1]);
                    allset.values.getDataRef()[line][i] = value;
                    line++;
                }
            }
        } catch (IOException e) {
            System.err.println("File Read Exception");
        }
    }
private synchronized jdbcResultSet executeHTTP(String s) throws SQLException {
        byte result[];
        try {
            URL url = new URL(sConnect);
            String p = StringConverter.unicodeToHexString(sUser);
            p += "+" + StringConverter.unicodeToHexString(sPassword);
            p += "+" + StringConverter.unicodeToHexString(s);
            URLConnection c = url.openConnection();
            c.setDoOutput(true);
            OutputStream os = c.getOutputStream();
            os.write(p.getBytes(ENCODING));
            os.close();
            c.connect();
            InputStream is = (InputStream) c.getContent();
            BufferedInputStream in = new BufferedInputStream(is);
            int len = c.getContentLength();
            result = new byte[len];
            for (int i = 0; i < len; i++) {
                int r = in.read();
                result[i] = (byte) r;
            }
        } catch (Exception e) {
            throw Trace.error(Trace.CONNECTION_IS_BROKEN, e.getMessage());
        }
        return new jdbcResultSet(new Result(result));
    }
protected File getFile(NameCategory category) throws IOException {
        File home = new File(System.getProperty("user.dir"));
        String fileName = String.format("%s.txt", category);
        File file = new File(home, fileName);
        if (file.exists()) {
            return file;
        } else {
            URL url = DefaultNameGenerator.class.getResource("/sc/common/" + fileName);
            if (url == null) {
                throw new IllegalStateException(String.format("Cannot find resource at %s", fileName));
            } else {
                InputStream in = url.openStream();
                try {
                    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
                    try {
                        IOUtils.copy(in, out);
                    } finally {
                        out.close();
                    }
                } finally {
                    in.close();
                }
                return file;
            }
        }
    }
@SuppressWarnings("unchecked")
    public static void zip(String input, OutputStream out) {
        File file = new File(input);
        ZipOutputStream zip = null;
        FileInputStream in = null;
        try {
            if (file.exists()) {
                Collection<File> items = new ArrayList();
                if (file.isDirectory()) {
                    items = FileUtils.listFiles(file, TrueFileFilter.INSTANCE, TrueFileFilter.INSTANCE);
                    zip = new ZipOutputStream(out);
                    zip.putNextEntry(new ZipEntry(file.getName() + "/"));
                    Iterator iter = items.iterator();
                    while (iter.hasNext()) {
                        File item = (File) iter.next();
                        in = new FileInputStream(item);
                        zip.putNextEntry(new ZipEntry(file.getName() + "/" + item.getName()));
                        IOUtils.copy(in, zip);
                        IOUtils.closeQuietly(in);
                        zip.closeEntry();
                    }
                    IOUtils.closeQuietly(zip);
                }
            } else {
                log.info("-->>���ļ���û���ļ�");
            }
        } catch (Exception e) {
            log.error("����ѹ��" + input + "�������", e);
            throw new RuntimeException("����ѹ��" + input + "�������", e);
        } finally {
            try {
                if (null != zip) {
                    zip.close();
                    zip = null;
                }
                if (null != in) {
                    in.close();
                    in = null;
                }
            } catch (Exception e) {
                log.error("�ر��ļ�������");
            }
        }
    }
@SuppressWarnings("unchecked")
    public static void unzip(String input, String output) {
        try {
            if (!output.endsWith("/")) output = output + "/";
            ZipFile zip = new ZipFile(input);
            Enumeration entries = zip.entries();
            while (entries.hasMoreElements()) {
                ZipEntry entry = (ZipEntry) entries.nextElement();
                if (entry.isDirectory()) {
                    FileUtils.forceMkdir(new File(output + entry.getName()));
                } else {
                    FileOutputStream out = new FileOutputStream(output + entry.getName());
                    IOUtils.copy(zip.getInputStream(entry), out);
                    IOUtils.closeQuietly(out);
                }
            }
        } catch (Exception e) {
            log.error("�����ҵ��ļ�:" + output, e);
            throw new RuntimeException("�����ҵ��ļ�:" + output, e);
        }
    }
public void createNewFile(String filePath, InputStream in) throws IOException {
        FileOutputStream out = null;
        try {
            File file = newFileRef(filePath);
            FileHelper.createNewFile(file, true);
            out = new FileOutputStream(file);
            IOUtils.copy(in, out);
        } finally {
            IOUtils.closeQuietly(in);
            IOUtils.closeQuietly(out);
        }
    }
public static void addProviders(URL url) {
        Reader reader = null;
        Properties prop = new Properties();
        try {
            reader = new InputStreamReader(url.openStream());
            prop.load(reader);
        } catch (Throwable t) {
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (Throwable t) {
                }
            }
        }
        for (Map.Entry<Object, Object> entry : prop.entrySet()) {
            try {
                Class<?> cla = Class.forName((String) entry.getValue(), true, Thread.currentThread().getContextClassLoader());
                providers.put(((String) entry.getKey()).toUpperCase(), (CharsetProvider) cla.newInstance());
            } catch (Throwable t) {
            }
        }
    }
private String fetchHTML(String s) {
        String str;
        StringBuffer sb = new StringBuffer();
        try {
            URL url = new URL(s);
            InputStream is = url.openStream();
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            while ((str = br.readLine()) != null) {
                sb.append(str);
            }
        } catch (MalformedURLException e) {
        } catch (IOException e) {
        }
        return sb.toString();
    }
public boolean check(Object credentials) {
            String password = (credentials instanceof String) ? (String) credentials : credentials.toString();
            try {
                MessageDigest md = MessageDigest.getInstance("MD5");
                byte[] ha1;
                if (credentials instanceof Credential.MD5) {
                    ha1 = ((Credential.MD5) credentials).getDigest();
                } else {
                    md.update(username.getBytes(StringUtil.__ISO_8859_1));
                    md.update((byte) ':');
                    md.update(realm.getBytes(StringUtil.__ISO_8859_1));
                    md.update((byte) ':');
                    md.update(password.getBytes(StringUtil.__ISO_8859_1));
                    ha1 = md.digest();
                }
                md.reset();
                md.update(method.getBytes(StringUtil.__ISO_8859_1));
                md.update((byte) ':');
                md.update(uri.getBytes(StringUtil.__ISO_8859_1));
                byte[] ha2 = md.digest();
                md.update(TypeUtil.toString(ha1, 16).getBytes(StringUtil.__ISO_8859_1));
                md.update((byte) ':');
                md.update(nonce.getBytes(StringUtil.__ISO_8859_1));
                md.update((byte) ':');
                md.update(nc.getBytes(StringUtil.__ISO_8859_1));
                md.update((byte) ':');
                md.update(cnonce.getBytes(StringUtil.__ISO_8859_1));
                md.update((byte) ':');
                md.update(qop.getBytes(StringUtil.__ISO_8859_1));
                md.update((byte) ':');
                md.update(TypeUtil.toString(ha2, 16).getBytes(StringUtil.__ISO_8859_1));
                byte[] digest = md.digest();
                return (TypeUtil.toString(digest, 16).equalsIgnoreCase(response));
            } catch (Exception e) {
                Log.warn(e);
            }
            return false;
        }
private synchronized Document executeHttpMethod(final HttpUriRequest httpRequest) throws UnauthorizedException, ThrottledException, ApiException {
        if (!isNextRequestAllowed()) {
            try {
                if (LOGGER.isDebugEnabled()) {
                    LOGGER.debug("Wait " + WAITING_TIME + "ms for request.");
                }
                wait(WAITING_TIME);
            } catch (InterruptedException ie) {
                throw new ApiException("Waiting for request interrupted.", ie);
            }
        }
        try {
            if (LOGGER.isDebugEnabled()) {
                LOGGER.debug("Perform request.");
            }
            HttpResponse httpResponse = httpClient.execute(httpRequest);
            switch(httpResponse.getStatusLine().getStatusCode()) {
                case HTTP_OK:
                    HttpEntity httpEntity = httpResponse.getEntity();
                    if (httpEntity != null) {
                        InputStream responseStream = httpEntity.getContent();
                        if (responseStream == null) {
                            throw new ApiException("TODO");
                        } else {
                            String response = null;
                            try {
                                response = IOUtils.toString(responseStream, RESPONSE_ENCODING);
                            } catch (IOException ioe) {
                                throw new ApiException("Problem reading response", ioe);
                            } catch (RuntimeException re) {
                                httpRequest.abort();
                                throw new ApiException("Problem reading response", re);
                            } finally {
                                responseStream.close();
                            }
                            StringReader responseReader = new StringReader(response);
                            Document document = documentBuilder.parse(new InputSource(responseReader));
                            return document;
                        }
                    }
                case HTTP_UNAVAILABLE:
                    throw new ThrottledException("TODO");
                case HTTP_UNAUTHORIZED:
                    throw new UnauthorizedException("TODO");
                default:
                    throw new ApiException("Unexpected HTTP status code: " + httpResponse.getStatusLine().getStatusCode());
            }
        } catch (SAXException se) {
            throw new ApiException("TODO", se);
        } catch (IOException ioe) {
            throw new ApiException("TODO", ioe);
        } finally {
            updateLastRequestTimestamp();
        }
    }
@Override
    public Document duplicate() {
        BinaryDocument b = new BinaryDocument(this.name, this.content.getContentType());
        try {
            IOUtils.copy(this.getContent().getInputStream(), this.getContent().getOutputStream());
            return b;
        } catch (IOException e) {
            throw ManagedIOException.manage(e);
        }
    }
private File copyFromURL(URL url, String dir) throws IOException {
        File urlFile = new File(url.getFile());
        File dest = new File(dir, urlFile.getName());
        logger.log("Extracting " + urlFile.getName() + " to " + dir + "...");
        FileOutputStream os = new FileOutputStream(dest);
        InputStream is = url.openStream();
        byte data[] = new byte[4096];
        int ct;
        while ((ct = is.read(data)) >= 0) os.write(data, 0, ct);
        is.close();
        os.close();
        logger.log("ok\n");
        return dest;
    }
@Override
    public void runTask(HashMap pjobParameters) throws Exception {
        if (hasRequiredResources(isSubTask())) {
            String lstrSource = getSourceFilename();
            String lstrTarget = getTargetFilename();
            if (getSourceDirectory() != null) {
                lstrSource = getSourceDirectory() + File.separator + getSourceFilename();
            }
            if (getTargetDirectory() != null) {
                lstrTarget = getTargetDirectory() + File.separator + getTargetFilename();
            }
            GZIPInputStream lgzipInput = new GZIPInputStream(new FileInputStream(lstrSource));
            OutputStream lfosGUnzip = new FileOutputStream(lstrTarget);
            byte[] buf = new byte[1024];
            int len;
            while ((len = lgzipInput.read(buf)) > 0) lfosGUnzip.write(buf, 0, len);
            lgzipInput.close();
            lfosGUnzip.close();
        }
    }
public static byte[] fetchURLData(String url, String proxyHost, int proxyPort) throws IOException {
        HttpURLConnection con = null;
        InputStream is = null;
        try {
            URL u = new URL(url);
            if (url.startsWith("file://")) {
                is = new BufferedInputStream(u.openStream());
            } else {
                Proxy proxy;
                if (proxyHost != null) {
                    proxy = new Proxy(Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
                } else {
                    proxy = Proxy.NO_PROXY;
                }
                con = (HttpURLConnection) u.openConnection(proxy);
                con.addRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.6 (KHTML, like Gecko) Chrome/20.0.1092.0 Safari/536.6");
                con.addRequestProperty("Accept-Charset", "UTF-8");
                con.addRequestProperty("Accept-Language", "en-US,en");
                con.addRequestProperty("Accept", "text/html,image/*");
                con.setDoInput(true);
                con.setDoOutput(false);
                con.connect();
                is = new BufferedInputStream(con.getInputStream());
            }
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            IOUtils.copy(is, baos);
            return baos.toByteArray();
        } finally {
            IOUtils.closeQuietly(is);
            if (con != null) {
                con.disconnect();
            }
        }
    }
private static String createBoundary(int number) {
        MessageDigest digest;
        try {
            digest = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
        digest.update(String.valueOf(Math.random()).getBytes());
        digest.update(String.valueOf(System.currentTimeMillis()).getBytes());
        digest.update(String.valueOf(digest.hashCode()).getBytes());
        byte[] bytes = digest.digest();
        String paddedNumber = Integer.toString(number);
        paddedNumber = ("0000000000".substring(0, 10 - paddedNumber.length()) + paddedNumber);
        StringBuffer buffer = new StringBuffer();
        buffer.append("---------------------------------=__");
        for (int i = 0; i < 8; i++) {
            String hex = Integer.toHexString((bytes[i] & 0xff) + 0x100).substring(1);
            buffer.append(hex);
        }
        buffer.append('_');
        buffer.append(paddedNumber);
        return buffer.toString();
    }
public void zip_compressFiles() throws Exception {
        FileInputStream in = null;
        File f1 = new File("C:\\WINDOWS\\regedit.exe");
        File f2 = new File("C:\\WINDOWS\\win.ini");
        File file = new File("C:\\" + NTUtil.class.getName() + ".zip");
        ZipOutputStream out = new ZipOutputStream(new FileOutputStream(file));
        out.putNextEntry(new ZipEntry("regedit.exe"));
        in = new FileInputStream(f1);
        while (in.available() > 0) {
            out.write(in.read());
        }
        in.close();
        out.closeEntry();
        out.putNextEntry(new ZipEntry("win.ini"));
        in = new FileInputStream(f2);
        while (in.available() > 0) {
            out.write(in.read());
        }
        in.close();
        out.closeEntry();
        out.close();
    }
public static void copyFile(String from, String to, boolean append) throws IOException {
        FileChannel in = new FileInputStream(from).getChannel();
        FileChannel out = new FileOutputStream(to, append).getChannel();
        ByteBuffer buffer = ByteBuffer.allocate(BSIZE);
        while (in.read(buffer) != -1) {
            buffer.flip();
            out.write(buffer);
            buffer.clear();
        }
    }
public void afficherMetar(String oaci) {
        if (oaci.length() != 4) {
            System.out.println("un code METAR est composé de 4 caracteres");
        }
        oaci.toUpperCase();
        try {
            URL url = new URL("http://weather.noaa.gov/pub/data/observations/metar/stations/" + oaci + ".TXT");
            System.out.println(url.toString());
            Proxy acReunion = new Proxy(Proxy.Type.HTTP, new InetSocketAddress("proxy.ac-reunion.fr", 8080));
            HttpURLConnection con = (HttpURLConnection) url.openConnection(acReunion);
            InputStreamReader isr = new InputStreamReader(con.getInputStream());
            BufferedReader in = new BufferedReader(isr);
            Vector vListe = new Vector();
            String line;
            System.out.println("Affichage METAR");
            System.out.println("--------");
            while ((line = in.readLine()) != null) {
                System.out.println(line);
                vListe.add(line);
            }
            System.out.println("--------");
            in.close();
        } catch (java.io.FileNotFoundException e) {
            System.out.println("Impossible de trouver le METAR");
            System.out.println(e);
        } catch (Exception e) {
            System.out.println(e.toString());
        }
    }