semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public List<Mosque> getAllMosquaisFromDataBase() {
        List<Mosque> mosquais = new ArrayList<Mosque>();
        InputStream is = null;
        String result = "";
        ArrayList<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
        if (MyMapActivity.DEVELOPER_MODE) {
            nameValuePairs.add(new BasicNameValuePair(Param.LATITUDE, MyMapActivity.mLatitude + ""));
            nameValuePairs.add(new BasicNameValuePair(Param.LONGITUDE, MyMapActivity.mLongitude + ""));
        } else {
            nameValuePairs.add(new BasicNameValuePair(Param.LATITUDE, MyMapActivity.myLocation.getLatitude() + ""));
            nameValuePairs.add(new BasicNameValuePair(Param.LONGITUDE, MyMapActivity.myLocation.getLongitude() + ""));
        }
        nameValuePairs.add(new BasicNameValuePair(Param.RAYON, DataBaseQuery.rayon * Param.KM_MARGE + ""));
        try {
            HttpClient httpclient = new DefaultHttpClient();
            HttpPost httppost = new HttpPost(Param.URI_SELECT_ALL_DATA_BASE);
            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            is = entity.getContent();
        } catch (Exception e) {
            Log.e("log_tag", "Error in http connection " + e.toString());
        }
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(is, "iso-8859-1"), 8);
            StringBuilder sb = new StringBuilder();
            String line = null;
            while ((line = reader.readLine()) != null) {
                sb.append(line + "\n");
            }
            is.close();
            result = sb.toString();
        } catch (Exception e) {
            Log.e("log_tag", "Error converting result " + e.toString());
        }
        try {
            JSONArray jArray = new JSONArray(result);
            for (int i = 0; i < jArray.length(); i++) {
                JSONObject json_data = jArray.getJSONObject(i);
                Mosque mosquai = new Mosque(json_data.getInt(Param.ID), json_data.getString(Param.NOM), json_data.getDouble(Param.LATITUDE), json_data.getDouble(Param.LONGITUDE), json_data.getString(Param.INFO), json_data.getInt(Param.HAVE_PICTURE) == 1 ? true : false, json_data.getString(Param.PICTURE));
                mosquais.add(mosquai);
            }
        } catch (JSONException e) {
            Log.e("log_tag", "Error parsing data " + e.toString());
        }
        return mosquais;
    }
public void loadFromInternet(boolean reload) {
        if (!reload && this.internetScoreGroupModel != null) {
            return;
        }
        loadingFlag = true;
        ProgressBar settingProgressBar = (ProgressBar) this.activity.findViewById(R.id.settingProgressBar);
        settingProgressBar.setVisibility(View.VISIBLE);
        final Timer timer = new Timer();
        final Handler handler = new Handler() {

            @Override
            public void handleMessage(Message msg) {
                if (loadingFlag == false) {
                    ProgressBar settingProgressBar = (ProgressBar) BestScoreExpandableListAdapter.this.activity.findViewById(R.id.settingProgressBar);
                    settingProgressBar.setVisibility(View.INVISIBLE);
                    timer.cancel();
                }
                super.handleMessage(msg);
            }
        };
        final TimerTask task = new TimerTask() {

            @Override
            public void run() {
                Message message = new Message();
                handler.sendMessage(message);
            }
        };
        timer.schedule(task, 1, 50);
        String httpUrl = Constants.SERVER_URL + "/rollingcard.php?op=viewbestscore";
        HttpGet request = new HttpGet(httpUrl);
        HttpClient httpClient = new DefaultHttpClient();
        try {
            HttpResponse response = httpClient.execute(request);
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                String entity = EntityUtils.toString(response.getEntity());
                String[] itemArray = entity.split(";");
                this.internetScoreGroupModel = new ScoreGroupModel();
                for (int i = 0; i < itemArray.length; i++) {
                    String[] itemValueArray = itemArray[i].split("\\|");
                    if (itemValueArray.length != 3) {
                        continue;
                    }
                    ScoreItemModel itemModel = new ScoreItemModel(itemValueArray[0], itemValueArray[1], itemValueArray[2]);
                    this.internetScoreGroupModel.addItem(itemModel);
                }
            }
        } catch (ClientProtocolException e) {
            this.internetScoreGroupModel = null;
            e.printStackTrace();
        } catch (IOException e) {
            this.internetScoreGroupModel = null;
            e.printStackTrace();
        }
        loadingFlag = false;
    }
public void copyFile(File in, File out) throws IOException {
        FileChannel inChannel = new FileInputStream(in).getChannel();
        FileChannel outChannel = new FileOutputStream(out).getChannel();
        try {
            int maxCount = (64 * 1024 * 1024) - (32 * 1024);
            long size = inChannel.size();
            long position = 0;
            while (position < size) {
                position += inChannel.transferTo(position, maxCount, outChannel);
            }
        } catch (IOException e) {
            throw e;
        } finally {
            if (inChannel != null) inChannel.close();
            if (outChannel != null) outChannel.close();
        }
    }
public static void main(String[] args) throws Exception {
        String uri = args[0];
        Configuration conf = new Configuration();
        FileSystem fs = FileSystem.get(URI.create(uri), conf);
        InputStream in = null;
        try {
            in = fs.open(new Path(uri));
            IOUtils.copyBytes(in, System.out, 4096, false);
        } finally {
            IOUtils.closeStream(in);
        }
    }
public static IProject createSimplemodelEnabledJavaProject() throws CoreException {
        IWorkspaceDescription desc = ResourcesPlugin.getWorkspace().getDescription();
        desc.setAutoBuilding(false);
        ResourcesPlugin.getWorkspace().setDescription(desc);
        String name = "TestProject";
        for (int i = 0; i < 1000; i++) {
            IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name + i);
            if (project.exists()) continue;
            project.create(null);
            project.open(null);
            IProjectDescription description = project.getDescription();
            String[] natures = description.getNatureIds();
            String[] newNatures = new String[natures.length + 2];
            System.arraycopy(natures, 0, newNatures, 0, natures.length);
            newNatures[natures.length] = JavaCore.NATURE_ID;
            newNatures[natures.length + 1] = SimplemodelNature.NATURE_ID;
            description.setNatureIds(newNatures);
            project.setDescription(description, null);
            IJavaProject javaProject = JavaCore.create(project);
            Set<IClasspathEntry> entries = new HashSet<IClasspathEntry>();
            IVMInstall vmInstall = JavaRuntime.getDefaultVMInstall();
            Path containerPath = new Path(JavaRuntime.JRE_CONTAINER);
            IPath vmPath = containerPath.append(vmInstall.getVMInstallType().getId()).append(vmInstall.getName());
            entries.add(JavaCore.newContainerEntry(vmPath));
            LibraryLocation[] locations = JavaRuntime.getLibraryLocations(vmInstall);
            for (LibraryLocation element : locations) {
                entries.add(JavaCore.newLibraryEntry(element.getSystemLibraryPath(), null, null));
            }
            final Path srcPath = new Path("src");
            final IFolder src = project.getFolder(srcPath);
            final Path binPath = new Path("bin");
            final IFolder bin = project.getFolder(binPath);
            src.create(true, true, null);
            bin.create(true, true, null);
            entries.add(JavaCore.newSourceEntry(project.getFullPath().append(srcPath)));
            javaProject.setOutputLocation(project.getFullPath().append(binPath), null);
            javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
            return project;
        }
        throw new RuntimeException("Failed");
    }
private static KeyStore createKeyStore(final URL url, final String password) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException {
        if (url == null) {
            throw new IllegalArgumentException("Keystore url may not be null");
        }
        LOG.debug("Initializing key store");
        KeyStore keystore = KeyStore.getInstance("jks");
        InputStream is = null;
        try {
            is = url.openStream();
            keystore.load(is, password != null ? password.toCharArray() : null);
        } finally {
            if (is != null) is.close();
        }
        return keystore;
    }
public int next() {
        int sequenceValue = current();
        try {
            Update update = dbi.getUpdate();
            update.setTableName(sequenceTable);
            update.assignValue("SEQUENCE_VALUE", --sequenceValue);
            Search search = new Search();
            search.addAttributeCriteria(sequenceTable, "SEQUENCE_NAME", Search.EQUAL, sequenceName);
            update.where(search);
            int affectedRows = dbi.getConnection().createStatement().executeUpdate(update.toString());
            if (affectedRows == 1) {
                dbi.getConnection().commit();
            } else {
                dbi.getConnection().rollback();
            }
        } catch (SQLException sqle) {
            System.err.println("SQLException occurred in current(): " + sqle.getMessage());
        }
        return sequenceValue;
    }
@Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String contentId = req.getParameter(CONTENT_ID);
        String contentType = req.getParameter(CONTENT_TYPE);
        if (contentId == null || contentType == null) {
            resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Content id or content type not specified");
            return;
        }
        try {
            switch(ContentType.valueOf(contentType)) {
                case IMAGE:
                    resp.setContentType("image/jpeg");
                    break;
                case AUDIO:
                    resp.setContentType("audio/mp3");
                    break;
                case VIDEO:
                    resp.setContentType("video/mpeg");
                    break;
                default:
                    throw new IllegalStateException("Invalid content type specified");
            }
        } catch (IllegalArgumentException e) {
            resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "Invalid content type specified");
            return;
        }
        String baseUrl = this.getServletContext().getInitParameter(BASE_URL);
        URL url = new URL(baseUrl + "/" + contentType.toLowerCase() + "/" + contentId);
        URLConnection conn = url.openConnection();
        resp.setContentLength(conn.getContentLength());
        IOUtils.copy(conn.getInputStream(), resp.getOutputStream());
    }
@Override
    public List<String> getNamedEntitites(String sentence) {
        List<String> namedEntities = new ArrayList<String>();
        try {
            URL url = new URL(SERVICE_URL + "text=" + URLEncoder.encode(sentence, "UTF-8") + "&confidence=" + CONFIDENCE + "&support=" + SUPPORT);
            URLConnection conn = url.openConnection();
            conn.setRequestProperty("accept", "application/json");
            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            StringBuffer sb = new StringBuffer();
            String line;
            while ((line = rd.readLine()) != null) {
                sb.append(line);
            }
            rd.close();
            JSONObject json = new JSONObject(sb.toString());
            if (!json.isNull("Resources")) {
                JSONArray array = json.getJSONArray("Resources");
                JSONObject entityObject;
                for (int i = 0; i < array.length(); i++) {
                    entityObject = array.getJSONObject(i);
                    System.out.println("Entity: " + entityObject.getString("@surfaceForm"));
                    System.out.println("DBpedia URI: " + entityObject.getString("@URI"));
                    System.out.println("Types: " + entityObject.getString("@types"));
                    namedEntities.add(entityObject.getString("@surfaceForm"));
                }
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return namedEntities;
    }
public static void main(String[] args) throws IOException {
        String urltext = "http://www.vogella.de";
        URL url = new URL(urltext);
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
        String inputLine;
        while ((inputLine = in.readLine()) != null) {
            System.out.println(inputLine);
        }
        in.close();
    }
public void connect(String method, String data, String urlString, Properties properties, boolean allowredirect) throws Exception {
        if (urlString != null) {
            try {
                url_ = new URL(url_, urlString);
            } catch (Exception e) {
                throw new Exception("Invalid URL");
            }
        }
        try {
            httpURLConnection_ = (HttpURLConnection) url_.openConnection(siteThread_.getProxy());
            httpURLConnection_.setDoInput(true);
            httpURLConnection_.setDoOutput(true);
            httpURLConnection_.setUseCaches(false);
            httpURLConnection_.setRequestMethod(method);
            httpURLConnection_.setRequestProperty("Content-type", "application/x-www-form-urlencoded");
            httpURLConnection_.setInstanceFollowRedirects(allowredirect);
            if (properties != null) {
                for (Object propertyKey : properties.keySet()) {
                    String propertyValue = properties.getProperty((String) propertyKey);
                    if (propertyValue.equalsIgnoreCase("Content-Length")) {
                        httpURLConnection_.setFixedLengthStreamingMode(0);
                    }
                    httpURLConnection_.setRequestProperty((String) propertyKey, propertyValue);
                }
            }
            int connectTimeout = httpURLConnection_.getConnectTimeout();
            if (data != null) {
                post(data);
            }
            httpURLConnection_.connect();
        } catch (Exception e) {
            throw new Exception("Connection failed with url " + url_);
        }
    }
boolean createSessionArchive(String archiveFilename) {
        byte[] buffer = new byte[1024];
        try {
            ZipOutputStream archive = new ZipOutputStream(new FileOutputStream(archiveFilename));
            for (mAnnotationsCursor.moveToFirst(); !mAnnotationsCursor.isAfterLast(); mAnnotationsCursor.moveToNext()) {
                FileInputStream in = new FileInputStream(mAnnotationsCursor.getString(ANNOTATIONS_FILE_NAME));
                archive.putNextEntry(new ZipEntry("audio" + (mAnnotationsCursor.getPosition() + 1) + ".3gpp"));
                int length;
                while ((length = in.read(buffer)) > 0) archive.write(buffer, 0, length);
                archive.closeEntry();
                in.close();
            }
            archive.close();
        } catch (IOException e) {
            Toast.makeText(mActivity, mActivity.getString(R.string.error_zip) + " " + e.getMessage(), Toast.LENGTH_SHORT).show();
            return false;
        }
        return true;
    }
public boolean authorize(String username, String password, String filename) {
        open(filename);
        boolean isAuthorized = false;
        StringBuffer encPasswd = null;
        try {
            MessageDigest mdAlgorithm = MessageDigest.getInstance("MD5");
            mdAlgorithm.update(password.getBytes());
            byte[] digest = mdAlgorithm.digest();
            encPasswd = new StringBuffer();
            for (int i = 0; i < digest.length; i++) {
                password = Integer.toHexString(255 & digest[i]);
                if (password.length() < 2) {
                    password = "0" + password;
                }
                encPasswd.append(password);
            }
        } catch (NoSuchAlgorithmException ex) {
        }
        String encPassword = encPasswd.toString();
        String tempPassword = getPassword(username);
        System.out.println("epass" + encPassword);
        System.out.println("pass" + tempPassword);
        if (tempPassword.equals(encPassword)) {
            isAuthorized = true;
        } else {
            isAuthorized = false;
        }
        close();
        return isAuthorized;
    }
public void addUser(String username, String password, String filename) {
        String data = "";
        try {
            open(filename);
            MessageDigest mdAlgorithm = MessageDigest.getInstance("MD5");
            mdAlgorithm.update(password.getBytes());
            byte[] digest = mdAlgorithm.digest();
            StringBuffer encPasswd = new StringBuffer();
            for (int i = 0; i < digest.length; i++) {
                password = Integer.toHexString(255 & digest[i]);
                if (password.length() < 2) {
                    password = "0" + password;
                }
                encPasswd.append(password);
                data = username + " " + encPasswd + "\r\n";
            }
            try {
                long length = file.length();
                file.seek(length);
                file.write(data.getBytes());
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            close();
        } catch (NoSuchAlgorithmException ex) {
        }
    }
public String encryptPassword(String password) {
        StringBuffer encPasswd = new StringBuffer();
        try {
            MessageDigest mdAlgorithm = MessageDigest.getInstance("MD5");
            mdAlgorithm.update(password.getBytes());
            byte[] digest = mdAlgorithm.digest();
            for (int i = 0; i < digest.length; i++) {
                password = Integer.toHexString(255 & digest[i]);
                if (password.length() < 2) {
                    password = "0" + password;
                }
                encPasswd.append(password);
            }
        } catch (NoSuchAlgorithmException ex) {
        }
        return encPasswd.toString();
    }
public String generateKey(Message msg) {
        String text = msg.getDefaultMessage();
        String meaning = msg.getMeaning();
        if (text == null) {
            return null;
        }
        MessageDigest md5;
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("Error initializing MD5", e);
        }
        try {
            md5.update(text.getBytes("UTF-8"));
            if (meaning != null) {
                md5.update(meaning.getBytes("UTF-8"));
            }
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException("UTF-8 unsupported", e);
        }
        return StringUtils.toHexString(md5.digest());
    }
private void parse() throws ComponentRegistryException {
        try {
            HttpURLConnection connection = (HttpURLConnection) this.url.openConnection();
            connection.setInstanceFollowRedirects(false);
            connection.connect();
            int count = 0;
            while (String.valueOf(connection.getResponseCode()).startsWith("3")) {
                String location = connection.getHeaderField("Location");
                logger.finest("Redirecting to " + location);
                connection.disconnect();
                this.url = new URL(location);
                connection = (HttpURLConnection) this.url.openConnection();
                connection.setInstanceFollowRedirects(false);
                connection.connect();
                count++;
                if (count > 10) {
                    throw new ComponentRegistryException("Too many redirect");
                }
            }
            InputStream inputStream = connection.getInputStream();
            InputStreamReader reader = new InputStreamReader(inputStream);
            HtmlRegistryParserCallback callback = new HtmlRegistryParserCallback();
            ParserDelegator parser = new ParserDelegator();
            parser.parse(reader, callback, false);
        } catch (IOException e) {
            throw new ComponentRegistryException(e);
        }
    }
private byte[] digestPassword(byte[] salt, String password) throws AuthenticationException {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(salt);
            md.update(password.getBytes("UTF8"));
            return md.digest();
        } catch (Exception e) {
            throw new AuthenticationException(MESSAGE_CONFIGURATION_ERROR_KEY, e);
        }
    }
private static ISimpleChemObjectReader createReader(URL url, String urlString, String type) throws CDKException {
        if (type == null) {
            type = "mol";
        }
        ISimpleChemObjectReader cor = null;
        cor = new MDLV2000Reader(getReader(url), Mode.RELAXED);
        try {
            ReaderFactory factory = new ReaderFactory();
            cor = factory.createReader(getReader(url));
            if (cor instanceof CMLReader) {
                cor = new CMLReader(urlString);
            }
        } catch (IOException ioExc) {
        } catch (Exception exc) {
        }
        if (cor == null) {
            if (type.equals(JCPFileFilter.cml) || type.equals(JCPFileFilter.xml)) {
                cor = new CMLReader(urlString);
            } else if (type.equals(JCPFileFilter.sdf)) {
                cor = new MDLV2000Reader(getReader(url));
            } else if (type.equals(JCPFileFilter.mol)) {
                cor = new MDLV2000Reader(getReader(url));
            } else if (type.equals(JCPFileFilter.inchi)) {
                try {
                    cor = new INChIReader(new URL(urlString).openStream());
                } catch (MalformedURLException e) {
                } catch (IOException e) {
                }
            } else if (type.equals(JCPFileFilter.rxn)) {
                cor = new MDLRXNV2000Reader(getReader(url));
            } else if (type.equals(JCPFileFilter.smi)) {
                cor = new SMILESReader(getReader(url));
            }
        }
        if (cor == null) {
            throw new CDKException(GT._("Could not determine file format"));
        }
        if (cor instanceof MDLV2000Reader) {
            try {
                BufferedReader in = new BufferedReader(getReader(url));
                String line;
                while ((line = in.readLine()) != null) {
                    if (line.equals("$$$$")) {
                        String message = GT._("It seems you opened a mol or sdf" + " file containing several molecules. " + "Only the first one will be shown");
                        JOptionPane.showMessageDialog(null, message, GT._("sdf-like file"), JOptionPane.INFORMATION_MESSAGE);
                        break;
                    }
                }
            } catch (IOException ex) {
            }
        }
        return cor;
    }