semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public List<Class<?>> getImplementingClasses(Class<?> ancestor, boolean searchAllClasspath) throws MutableClassLoaderException {
        List<Class<?>> classes = new LinkedList<Class<?>>();
        for (URL url : (searchAllClasspath ? getURLs() : getAddedURLs())) {
            Log.verbose("Checking classpath item " + url);
            if (!url.getPath().toLowerCase().endsWith("/")) {
                try {
                    JarInputStream jis = new JarInputStream(url.openStream());
                    JarEntry je;
                    while ((je = jis.getNextJarEntry()) != null) {
                        Log.verbose("Checking resource " + je.getName());
                        try {
                            if (je.getName().endsWith(".class")) {
                                Class<?> c = this.loadClass(je.getName().replaceAll("/", ".").replaceAll(".class$", ""));
                                if (!Modifier.isAbstract(c.getModifiers()) && !Modifier.isInterface(c.getModifiers()) && ancestor.isAssignableFrom(c)) {
                                    Log.verbose("Found class " + c.getCanonicalName() + " which implements class " + ancestor.getCanonicalName());
                                    classes.add(c);
                                }
                            }
                        } catch (Error e) {
                        } catch (RuntimeException re) {
                        } catch (Exception e) {
                        }
                    }
                } catch (Exception e) {
                    Log.error(e);
                }
            } else if (url.getPath().endsWith("/")) {
                File root = new File(url.getPath());
                for (File file : FileFunctions.getFileTree(root)) {
                    try {
                        if (file.getName().toLowerCase().endsWith(".class")) {
                            Class<?> c = this.loadClass(file.getAbsolutePath().replaceAll("^" + root.getAbsolutePath() + "/", "").replaceAll("/", ".").replaceAll(".class$", ""));
                            if (!Modifier.isAbstract(c.getModifiers()) && !Modifier.isInterface(c.getModifiers()) && ancestor.isAssignableFrom(c)) {
                                Log.verbose("Found class " + c.getCanonicalName() + " which implements class " + ancestor.getCanonicalName());
                                classes.add(c);
                            }
                        }
                    } catch (Exception e) {
                        Log.error(e);
                    }
                }
            }
        }
        return classes;
    }
public String htmlContentSimple(String urlStr, String charset) {
        StringBuffer html = new StringBuffer();
        URL url = null;
        BufferedReader reader = null;
        try {
            url = new URL(urlStr);
            reader = new BufferedReader(new InputStreamReader(url.openStream(), charset));
            String line;
            while ((line = reader.readLine()) != null) {
                html.append(line).append("\r\n");
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (reader != null) try {
                reader.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return html.toString();
    }
public static String encryptPassword(String password) {
        String hash = null;
        try {
            MessageDigest md = null;
            md = MessageDigest.getInstance("SHA");
            md.update(password.getBytes("UTF-8"));
            byte raw[] = md.digest();
            hash = Base64.encode(raw, false);
        } catch (Exception e) {
        }
        return hash;
    }
@Override
    protected Map<String, Definition> loadDefinitionsFromURL(URL url) {
        Map<String, Definition> defsMap = null;
        try {
            URLConnection connection = url.openConnection();
            connection.connect();
            lastModifiedDates.put(url.toExternalForm(), connection.getLastModified());
            defsMap = reader.read(connection.getInputStream());
        } catch (IOException e) {
            if (log.isDebugEnabled()) {
                log.debug("File " + null + " not found, continue [" + e.getMessage() + "]");
            }
        }
        return defsMap;
    }
public String getScenarioData(String urlForSalesData) throws IOException, Exception {
        InputStream inputStream = null;
        BufferedReader bufferedReader = null;
        DataInputStream input = null;
        StringBuffer sBuf = new StringBuffer();
        Proxy proxy;
        if (httpWebProxyServer != null && Integer.toString(httpWebProxyPort) != null) {
            SocketAddress address = new InetSocketAddress(httpWebProxyServer, httpWebProxyPort);
            proxy = new Proxy(Proxy.Type.HTTP, address);
        } else {
            proxy = null;
        }
        proxy = null;
        URL url;
        try {
            url = new URL(urlForSalesData);
            HttpURLConnection httpUrlConnection;
            if (proxy != null) httpUrlConnection = (HttpURLConnection) url.openConnection(proxy); else httpUrlConnection = (HttpURLConnection) url.openConnection();
            httpUrlConnection.setDoInput(true);
            httpUrlConnection.setRequestMethod("GET");
            String name = rb.getString("WRAP_NAME");
            String password = rb.getString("WRAP_PASSWORD");
            Credentials simpleAuthCrentials = new Credentials(TOKEN_TYPE.SimpleApiAuthToken, name, password);
            ACSTokenProvider tokenProvider = new ACSTokenProvider(httpWebProxyServer, httpWebProxyPort, simpleAuthCrentials);
            String requestUriStr1 = "https://" + solutionName + "." + acmHostName + "/" + serviceName;
            String appliesTo1 = rb.getString("SIMPLEAPI_APPLIES_TO");
            String token = tokenProvider.getACSToken(requestUriStr1, appliesTo1);
            httpUrlConnection.addRequestProperty("token", "WRAPv0.9 " + token);
            httpUrlConnection.addRequestProperty("solutionName", solutionName);
            httpUrlConnection.connect();
            if (httpUrlConnection.getResponseCode() == HttpServletResponse.SC_UNAUTHORIZED) {
                List<TestSalesOrderService> salesOrderServiceBean = new ArrayList<TestSalesOrderService>();
                TestSalesOrderService response = new TestSalesOrderService();
                response.setResponseCode(HttpServletResponse.SC_UNAUTHORIZED);
                response.setResponseMessage(httpUrlConnection.getResponseMessage());
                salesOrderServiceBean.add(response);
            }
            inputStream = httpUrlConnection.getInputStream();
            input = new DataInputStream(inputStream);
            bufferedReader = new BufferedReader(new InputStreamReader(input));
            String str;
            while (null != ((str = bufferedReader.readLine()))) {
                sBuf.append(str);
            }
            String responseString = sBuf.toString();
            return responseString;
        } catch (MalformedURLException e) {
            throw e;
        } catch (IOException e) {
            throw e;
        }
    }
@HttpAction(name = "map.saveOrUpdate", method = { HttpAction.Method.post }, responseType = "text/plain")
    @HttpAuthentication(method = { HttpAuthentication.Method.WSSE })
    public String saveOrUpdate(FileItem file, User user, MapOriginal map) throws HttpRpcException {
        File tmpFile;
        GenericDAO<MapOriginal> mapDao = DAOFactory.createDAO(MapOriginal.class);
        try {
            assert (file != null);
            String jobid = null;
            if (file.getContentType().startsWith("image/")) {
                tmpFile = File.createTempFile("gmap", "img");
                OutputStream out = new FileOutputStream(tmpFile);
                IOUtils.copy(file.getInputStream(), out);
                out.flush();
                out.close();
                map.setState(MapOriginal.MapState.UPLOAD);
                map.setUser(user);
                map.setMapPath(tmpFile.getPath());
                map.setThumbnailUrl("/map/inproc.gif");
                map.setMimeType(file.getContentType());
                mapDao.saveOrUpdate(map);
                jobid = PoolFactory.getClientPool().put(map, TaskState.STATE_MO_FINISH, MapOverrideStrategy.class);
            }
            return jobid;
        } catch (IOException e) {
            logger.error(e);
            throw ERROR_INTERNAL;
        } catch (DAOException e) {
            logger.error(e);
            throw ERROR_INTERNAL;
        }
    }
public PhoneDurationsImpl(URL url) throws IOException {
        BufferedReader reader;
        String line;
        phoneDurations = new HashMap();
        reader = new BufferedReader(new InputStreamReader(url.openStream()));
        line = reader.readLine();
        while (line != null) {
            if (!line.startsWith("***")) {
                parseAndAdd(line);
            }
            line = reader.readLine();
        }
        reader.close();
    }
protected String getPasswordHash(String password) {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            log.error("MD5 algorithm not found", e);
            throw new ServiceException(e);
        }
        md.update(password.getBytes());
        byte[] hash = md.digest();
        StringBuffer buf = new StringBuffer();
        for (int i = 0; i < hash.length; i++) {
            buf.append(Integer.toHexString(hash[i] & 0xff));
        }
        return buf.toString();
    }
public static Node carregaModeloJME(String caminho) {
        try {
            URL urlModelo = ModelUtils.class.getClassLoader().getResource(caminho);
            BufferedInputStream leitorBinario = new BufferedInputStream(urlModelo.openStream());
            Node modelo = (Node) BinaryImporter.getInstance().load(leitorBinario);
            modelo.setModelBound(new BoundingBox());
            modelo.updateModelBound();
            return modelo;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
public void prepareOutput(HttpServletRequest req) {
        EaasyStreet.logTrace(METHOD_IN + className + OUTPUT_METHOD);
        super.prepareOutput(req);
        String content = Constants.EMPTY_STRING;
        String rawContent = null;
        List parts = null;
        try {
            URL url = new URL(sourceUrl);
            BufferedReader input = new BufferedReader(new InputStreamReader(url.openStream()));
            String line = "";
            StringBuffer buffer = new StringBuffer();
            while ((line = input.readLine()) != null) {
                buffer.append(line);
                buffer.append(Constants.LF);
            }
            rawContent = buffer.toString();
        } catch (FileNotFoundException nf) {
            req.setAttribute(Constants.RAK_SYSTEM_ACTION, Constants.SYSTEM_ACTION_BACK);
            EaasyStreet.handleSafeEvent(req, new Event(Constants.EAA0012I, new String[] { "URL", nf.getMessage(), nf.toString() }));
        } catch (Exception e) {
            req.setAttribute(Constants.RAK_SYSTEM_ACTION, Constants.SYSTEM_ACTION_BACK);
            EaasyStreet.handleSafeEvent(req, new Event(Constants.EAA0012I, new String[] { "URL", e.getMessage(), e.toString() }));
        }
        if (rawContent != null) {
            if (startDelimiter != null) {
                parts = StringUtils.split(rawContent, startDelimiter);
                if (parts != null && parts.size() > 1) {
                    rawContent = (String) parts.get(1);
                    if (parts.size() > 2) {
                        for (int x = 2; x < parts.size(); x++) {
                            rawContent += startDelimiter;
                            rawContent += parts.get(x);
                        }
                    }
                } else {
                    rawContent = null;
                }
            }
        }
        if (rawContent != null) {
            if (endDelimiter != null) {
                parts = StringUtils.split(rawContent, endDelimiter);
                if (parts != null && parts.size() > 0) {
                    rawContent = (String) parts.get(0);
                } else {
                    rawContent = null;
                }
            }
        }
        if (rawContent != null) {
            if (replacementValues != null && !replacementValues.isEmpty()) {
                for (int x = 0; x < replacementValues.size(); x++) {
                    LabelValueBean bean = (LabelValueBean) replacementValues.get(x);
                    rawContent = StringUtils.replace(rawContent, bean.getLabel(), bean.getValue());
                }
            }
        }
        if (rawContent != null) {
            content = rawContent;
        }
        req.setAttribute(getFormName(), content);
        EaasyStreet.logTrace(METHOD_OUT + className + OUTPUT_METHOD);
    }
public static boolean downFile(String url, String username, String password, String remotePath, Date DBLastestDate, String localPath) {
        File dFile = new File(localPath);
        if (!dFile.exists()) {
            dFile.mkdir();
        }
        boolean success = false;
        FTPClient ftp = new FTPClient();
        ftp.setConnectTimeout(connectTimeout);
        System.out.println("FTP begin!!");
        try {
            int reply;
            ftp.connect(url);
            ftp.login(username, password);
            reply = ftp.getReplyCode();
            if (!FTPReply.isPositiveCompletion(reply)) {
                ftp.disconnect();
                return success;
            }
            ftp.changeWorkingDirectory(remotePath);
            String[] filesName = ftp.listNames();
            if (DBLastestDate == null) {
                System.out.println(" 初次下载，全部下载 ");
                for (String string : filesName) {
                    if (!string.matches("[0-9]{12}")) {
                        continue;
                    }
                    File localFile = new File(localPath + "/" + string);
                    OutputStream is = new FileOutputStream(localFile);
                    ftp.retrieveFile(string, is);
                    is.close();
                }
            } else {
                System.out.println(" 加一下载 ");
                Date date = DBLastestDate;
                long ldate = date.getTime();
                Date nowDate = new Date();
                String nowDateStr = Constants.DatetoString(nowDate, Constants.Time_template_LONG);
                String fileName;
                do {
                    ldate += 60 * 1000;
                    Date converterDate = new Date(ldate);
                    fileName = Constants.DatetoString(converterDate, Constants.Time_template_LONG);
                    File localFile = new File(localPath + "/" + fileName);
                    OutputStream is = new FileOutputStream(localFile);
                    if (!ftp.retrieveFile(fileName, is)) {
                        localFile.delete();
                    }
                    is.close();
                } while (fileName.compareTo(nowDateStr) < 0);
            }
            ftp.logout();
            success = true;
        } catch (IOException e) {
            System.out.println("FTP timeout return");
            e.printStackTrace();
        } finally {
            if (ftp.isConnected()) {
                try {
                    ftp.disconnect();
                } catch (IOException ioe) {
                }
            }
        }
        return success;
    }
private void getRandomGUID(boolean secure) {
        MessageDigest md5 = null;
        StringBuffer sbValueBeforeMD5 = new StringBuffer();
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
        }
        try {
            long time = System.currentTimeMillis();
            long rand = 0;
            if (secure) {
                rand = mySecureRand.nextLong();
            } else {
                rand = myRand.nextLong();
            }
            sbValueBeforeMD5.append(s_id);
            sbValueBeforeMD5.append(":");
            sbValueBeforeMD5.append(Long.toString(time));
            sbValueBeforeMD5.append(":");
            sbValueBeforeMD5.append(Long.toString(rand));
            valueBeforeMD5 = sbValueBeforeMD5.toString();
            md5.update(valueBeforeMD5.getBytes());
            byte[] array = md5.digest();
            StringBuffer sb = new StringBuffer();
            for (int j = 0; j < array.length; ++j) {
                int b = array[j] & 0xFF;
                if (b < 0x10) sb.append('0');
                sb.append(Integer.toHexString(b));
            }
            valueAfterMD5 = sb.toString();
        } catch (Exception e) {
            System.out.println("Error:" + e);
        }
    }
public static String CreateHash(String s) {
        String str = s.toString();
        if (str == null || str.length() == 0) {
            throw new IllegalArgumentException("String cannot be null or empty");
        }
        StringBuffer hexString = new StringBuffer();
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(str.getBytes());
            byte[] hash = md.digest();
            for (int i = 0; i < hash.length; i++) {
                if ((0xff & hash[i]) < 0x10) {
                    hexString.append("0" + Integer.toHexString((0xFF & hash[i])));
                } else {
                    hexString.append(Integer.toHexString(0xFF & hash[i]));
                }
            }
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return (hexString.toString());
    }
public static String getHash(String uri) throws NoSuchAlgorithmException {
        MessageDigest mDigest = MessageDigest.getInstance("MD5");
        mDigest.update(uri.getBytes());
        byte d[] = mDigest.digest();
        StringBuffer hash = new StringBuffer();
        for (int i = 0; i < d.length; i++) {
            hash.append(Integer.toHexString(0xFF & d[i]));
        }
        return hash.toString();
    }
public DoSearch(String searchType, String searchString) {
        String urlString = dms_url + "/servlet/com.ufnasoft.dms.server.ServerDoSearch";
        String rvalue = "";
        String filename = dms_home + FS + "temp" + FS + username + "search.xml";
        try {
            String urldata = urlString + "?username=" + URLEncoder.encode(username, "UTF-8") + "&key=" + key + "&search=" + URLEncoder.encode(searchString, "UTF-8") + "&searchtype=" + URLEncoder.encode(searchType, "UTF-8") + "&filename=" + URLEncoder.encode(username, "UTF-8") + "search.xml";
            ;
            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
            DocumentBuilder parser = factory.newDocumentBuilder();
            URL u = new URL(urldata);
            DataInputStream is = new DataInputStream(u.openStream());
            FileOutputStream os = new FileOutputStream(filename);
            int iBufSize = is.available();
            byte inBuf[] = new byte[20000 * 1024];
            int iNumRead;
            while ((iNumRead = is.read(inBuf, 0, iBufSize)) > 0) os.write(inBuf, 0, iNumRead);
            os.close();
            is.close();
            File f = new File(filename);
            InputStream inputstream = new FileInputStream(f);
            Document document = parser.parse(inputstream);
            NodeList nodelist = document.getElementsByTagName("entry");
            int num = nodelist.getLength();
            searchDocs = new String[num][3];
            searchDocImageName = new String[num];
            searchDocsToolTip = new String[num];
            for (int i = 0; i < num; i++) {
                searchDocs[i][0] = DOMUtil.getSimpleElementText((Element) nodelist.item(i), "filename");
                searchDocs[i][1] = DOMUtil.getSimpleElementText((Element) nodelist.item(i), "project");
                searchDocs[i][2] = DOMUtil.getSimpleElementText((Element) nodelist.item(i), "documentid");
                searchDocImageName[i] = DOMUtil.getSimpleElementText((Element) nodelist.item(i), "imagename");
                searchDocsToolTip[i] = DOMUtil.getSimpleElementText((Element) nodelist.item(i), "description");
            }
        } catch (MalformedURLException ex) {
            System.out.println(ex);
        } catch (ParserConfigurationException ex) {
            System.out.println(ex);
        } catch (Exception ex) {
            System.out.println(ex);
        }
        System.out.println(rvalue);
        if (rvalue.equalsIgnoreCase("yes")) {
        }
    }
public String getUser() {
        try {
            HttpGet get = new HttpGet("http://twemoi.status.net/api/account/verify_credentials.xml");
            consumer.sign(get);
            HttpClient client = new DefaultHttpClient();
            HttpResponse response = client.execute(get);
            if (response != null) {
                int statusCode = response.getStatusLine().getStatusCode();
                if (statusCode != 200) {
                    this.enviarMensaje("Error: Usuario no autenticado en la red de Status");
                    return "";
                }
                StringBuffer sBuf = new StringBuffer();
                String linea;
                BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
                while ((linea = reader.readLine()) != null) {
                    sBuf.append(linea);
                }
                reader.close();
                response.getEntity().consumeContent();
                get.abort();
                String salida = sBuf.toString();
                String user_name = salida.split("</screen_name>")[0].split("<screen_name>")[1];
                return user_name;
            }
        } catch (UnsupportedEncodingException e) {
            this.enviarMensaje("Error: Usuario no autenticado en la red de Status");
        } catch (IOException e) {
            this.enviarMensaje("Error: Usuario no autenticado en la red de Status");
        } catch (OAuthMessageSignerException e) {
            this.enviarMensaje("Error: Usuario no autenticado en la red de Status");
        } catch (OAuthExpectationFailedException e) {
            this.enviarMensaje("Error: Usuario no autenticado en la red de Status");
        } catch (OAuthCommunicationException e) {
            this.enviarMensaje("Error: Usuario no autenticado en la red de Status");
        }
        return null;
    }
protected String getOldHash(String text) {
        String hash = null;
        try {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(text.getBytes("UTF-8"));
            byte[] digestedBytes = md.digest();
            hash = HexUtils.convert(digestedBytes);
        } catch (NoSuchAlgorithmException e) {
            log.log(Level.SEVERE, "Error creating SHA password hash:" + e.getMessage());
            hash = text;
        } catch (UnsupportedEncodingException e) {
            log.log(Level.SEVERE, "UTF-8 not supported!?!");
        }
        return hash;
    }