semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
void getAddress(String lat, String lag) {
        try {
            URL url = new URL("http://maps.google.cn/maps/geo?key=abcdefg&q=" + lat + "," + lag);
            InputStream inputStream = url.openConnection().getInputStream();
            InputStreamReader inputReader = new InputStreamReader(inputStream, "utf-8");
            BufferedReader bufReader = new BufferedReader(inputReader);
            String line = "", lines = "";
            while ((line = bufReader.readLine()) != null) {
                lines += line;
            }
            if (!lines.equals("")) {
                JSONObject jsonobject = new JSONObject(lines);
                JSONArray jsonArray = new JSONArray(jsonobject.get("Placemark").toString());
                for (int i = 0; i < jsonArray.length(); i++) {
                    mTextView.setText(mTextView.getText() + "\n" + jsonArray.getJSONObject(i).getString("address"));
                }
            }
        } catch (Exception e) {
            ;
        }
    }
public String md5(String plainText) throws NoSuchAlgorithmException {
        MessageDigest md = MessageDigest.getInstance("MD5");
        md.update(plainText.getBytes());
        byte[] digest = md.digest();
        StringBuffer hexString = new StringBuffer();
        for (int i = 0; i < digest.length; i++) {
            plainText = Integer.toHexString(0xFF & digest[i]);
            if (plainText.length() < 2) {
                plainText = "0" + plainText;
            }
            hexString.append(plainText);
        }
        return hexString.toString();
    }
@Test
    public void testRegisterOwnJceProvider() throws Exception {
        MyTestProvider provider = new MyTestProvider();
        assertTrue(-1 != Security.addProvider(provider));
        MessageDigest messageDigest = MessageDigest.getInstance("SHA-1", MyTestProvider.NAME);
        assertEquals(MyTestProvider.NAME, messageDigest.getProvider().getName());
        messageDigest.update("hello world".getBytes());
        byte[] result = messageDigest.digest();
        Assert.assertArrayEquals("hello world".getBytes(), result);
        Security.removeProvider(MyTestProvider.NAME);
    }
private void initClientConfigurationFromURL(String urlStr) throws Exception {
        try {
            URL url = ProxyURLFactory.createHttpUrl(urlStr);
            initClientConfiguration(url.openStream());
        } catch (Exception e) {
            throw new Exception("Could not initialize from Client Configuration URL:" + urlStr, e);
        }
    }
public void sortingByBubble(int[] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array.length - 1 - i; j++) {
                if (array[j] > array[j + 1]) {
                    int temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                }
            }
        }
    }
public void modifyBubble(int[] array) {
        for (int i = 0; i < array.length; i++) {
            if (i % 2 != 0) {
                for (int j = array.length - i / 2 - 2; j >= i / 2; j--) {
                    if (array[j] >= array[j + 1]) {
                        int temp = array[j];
                        array[j] = array[j + 1];
                        array[j + 1] = temp;
                    }
                }
            } else {
                for (int j = i / 2; j < array.length - 1 - i / 2; j++) {
                    if (array[j] >= array[j + 1]) {
                        int temp = array[j];
                        array[j] = array[j + 1];
                        array[j + 1] = temp;
                    }
                }
            }
        }
    }
public static synchronized String encrypt(String plaintextPassword) throws Exception {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("SHA");
        } catch (NoSuchAlgorithmException e) {
            throw new Exception(e);
        }
        try {
            md.update(plaintextPassword.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new Exception(e);
        }
        byte raw[] = md.digest();
        String hash = (new BASE64Encoder()).encode(raw);
        return hash;
    }
public void load(URL url) throws IOException {
        try {
            oggBitStream_ = new BufferedInputStream(url.openStream());
        } catch (Exception ex) {
            System.err.println("ogg file " + url + " could not be loaded");
        }
        load();
    }
public static boolean isODF(URL url) throws IOException {
        InputStream resStream = ODFUtil.findDataInputStream(url.openStream(), ODFUtil.MIMETYPE_FILE);
        if (null == resStream) {
            LOG.debug("mimetype stream not found in ODF package");
            return false;
        }
        String mimetypeContent = IOUtils.toString(resStream);
        return mimetypeContent.startsWith(ODFUtil.MIMETYPE_START);
    }
public byte[] loadClassFirst(final String className) {
        if (className.equals("com.sun.sgs.impl.kernel.KernelContext")) {
            final URL url = Thread.currentThread().getContextClassLoader().getResource("com/sun/sgs/impl/kernel/KernelContext.0.9.7.class.bin");
            if (url != null) {
                try {
                    return StreamUtil.read(url.openStream());
                } catch (IOException e) {
                }
            }
            throw new IllegalStateException("Unable to load KernelContext.0.9.7.class.bin");
        }
        return null;
    }
public static String crypt(String passwd, boolean pad) {
        try {
            MessageDigest sha = MessageDigest.getInstance("SHA-1");
            sha.update(passwd.getBytes());
            String c = new String(sha.digest());
            return toNumeric(c, pad, true);
        } catch (java.security.NoSuchAlgorithmException e) {
            Log.error(Login.class, "couldn't crypt()", e);
            return "";
        }
    }
private void parseUrl() {
            URLLexer lexer;
            URLParser parser;
            if (this.parent != null) {
                this.hops = ((HTTPFile) this.parent).hops - 1;
            }
            if (this.searchFilter.accept(this.url.getPath())) {
                if (!visited.contains(this.url.toExternalForm())) {
                    if (this.hops > 0) {
                        try {
                            visited.add(this.url.toExternalForm());
                            InputStream in = this.url.openStream();
                            lexer = new URLLexer(this.url.openStream());
                            parser = new URLParser(lexer);
                            URL[] urls = parser.htmlDocument(this.url);
                            if (Debug.debug) {
                                Debug.getInstance().info(this.getClass().getName() + ".parseUrl(): Found the following URLs in " + this.url.toExternalForm() + " : " + StringUtil.ArrayToString(urls, 10));
                            }
                            for (int i = 0; i < urls.length; i++) {
                                this.addInternal(urls[i]);
                            }
                        } catch (IOException e) {
                            if (Debug.debug) {
                                Debug.getInstance().error(e.getMessage());
                            }
                        } catch (RecognitionException e) {
                            if (Debug.debug) {
                                Debug.getInstance().error("Problems while lexing " + this.url.toExternalForm() + " : " + e.getMessage(), e);
                            }
                        } catch (TokenStreamException e) {
                            if (Debug.debug) {
                                Debug.getInstance().error("Problems while parsing " + this.url.toExternalForm() + " : " + e.getMessage(), e);
                            }
                        }
                    }
                } else {
                    if (Debug.debug) {
                        Debug.getInstance().info(this.getClass().getName() + ".parseUrl(): Skipping URL " + this.url.toExternalForm() + " : Maximum depth reached.");
                    }
                }
            } else {
                if (Debug.debug) {
                    Debug.getInstance().info(this.getClass().getName() + ".parseUrl(): Skipping URL " + this.url.toExternalForm() + " : Already parsed.");
                }
            }
        }
public static void ftpUpload(FTPConfig config, String directory, File file, String remoteFileName) throws IOException {
        FTPClient server = new FTPClient();
        server.connect(config.host, config.port);
        assertValidReplyCode(server.getReplyCode(), server);
        server.login(config.userName, config.password);
        assertValidReplyCode(server.getReplyCode(), server);
        assertValidReplyCode(server.cwd(directory), server);
        server.setFileTransferMode(FTP.IMAGE_FILE_TYPE);
        server.setFileType(FTP.IMAGE_FILE_TYPE);
        server.storeFile(remoteFileName, new FileInputStream(file));
        assertValidReplyCode(server.getReplyCode(), server);
        server.sendNoOp();
        server.disconnect();
    }
private static void ftpTest() {
        FTPClient f = new FTPClient();
        try {
            f.connect("oscomak.net");
            System.out.print(f.getReplyString());
            f.setFileType(FTPClient.BINARY_FILE_TYPE);
        } catch (SocketException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        String password = JOptionPane.showInputDialog("Enter password");
        if (password == null || password.equals("")) {
            System.out.println("No password");
            return;
        }
        try {
            f.login("oscomak_pointrel", password);
            System.out.print(f.getReplyString());
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            String workingDirectory = f.printWorkingDirectory();
            System.out.println("Working directory: " + workingDirectory);
            System.out.print(f.getReplyString());
        } catch (IOException e1) {
            e1.printStackTrace();
        }
        try {
            f.enterLocalPassiveMode();
            System.out.print(f.getReplyString());
            System.out.println("Trying to list files");
            String[] fileNames = f.listNames();
            System.out.print(f.getReplyString());
            System.out.println("Got file list fileNames: " + fileNames.length);
            for (String fileName : fileNames) {
                System.out.println("File: " + fileName);
            }
            System.out.println();
            System.out.println("done reading stream");
            System.out.println("trying alterative way to read stream");
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            f.retrieveFile(fileNames[0], outputStream);
            System.out.println("size: " + outputStream.size());
            System.out.println(outputStream.toString());
            System.out.println("done with alternative");
            System.out.println("Trying to store file back");
            ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
            boolean storeResult = f.storeFile("test.txt", inputStream);
            System.out.println("Done storing " + storeResult);
            f.disconnect();
            System.out.print(f.getReplyString());
            System.out.println("disconnected");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
public static void main(String argv[]) {
        String cp = System.getProperty("java.class.path");
        String sep = System.getProperty("file.separator");
        String dirpath = cp.substring(0, cp.lastIndexOf(sep));
        String jarpath = dirpath + "/WiiRemoteJ.jar";
        if (!new File(jarpath).exists()) {
            try {
                System.out.println("getting WiiRemoteJ file from remote source...");
                URL wiiRemLoc = new URL("http://www.world-of-cha0s.hostrocket.com/WiiRemoteJ/WiiRemoteJ%20v1.5.zip.gz");
                GZIPInputStream input = new GZIPInputStream(wiiRemLoc.openStream());
                String temploc = copyInputStreamToTmpFile(input, ".zip");
                ZipInputStream zipIn = new ZipInputStream(new FileInputStream(temploc));
                ZipEntry i = null;
                while ((i = zipIn.getNextEntry()) != null) {
                    if (i.getName().endsWith("WiiRemoteJ.jar")) {
                        File outjar = new File(jarpath);
                        BufferedOutputStream fs = new BufferedOutputStream(new FileOutputStream(outjar));
                        int bufferSize = 8192;
                        byte[] buffer = new byte[bufferSize];
                        int readSize = 0;
                        while ((readSize = zipIn.read(buffer, 0, bufferSize)) != -1) {
                            fs.write(buffer, 0, readSize);
                        }
                        fs.close();
                    }
                }
                System.out.println("unpacked into classpath.");
            } catch (MalformedURLException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        Boogiepants.main(argv);
    }
public String generateKey(String className, String methodName, String text, String meaning) {
        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());
    }
public static String md5Encode(String pass) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(pass.getBytes());
            byte[] result = md.digest();
            return bytes2hexStr(result);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException("La librería java.security no implemente MD5");
        }
    }
public void openUrlActionPerformed(ActionEvent event) {
        RemoteFileChooser fileChooser = new RemoteFileChooser(this, getAppName());
        fileChooser.getDialog().setVisible(true);
        if (fileChooser.getResult() == JOptionPane.OK_OPTION) {
            setCursorBusy(true);
            URL url = fileChooser.getSelectedUrl();
            String filename = fileChooser.getSelectedFilename();
            try {
                BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
                openFile(filename, reader);
            } catch (IOException e) {
                handleException(e);
            }
            setCursorBusy(false);
        }
        checkActions();
    }
private boolean setPayload() throws IOException {
        if (Index < Headers.length) {
            FileOutputStream fos = new FileOutputStream(Headers[Index], true);
            FileInputStream fis = new FileInputStream(HeadlessData);
            FileChannel fic = fis.getChannel();
            FileChannel foc = fos.getChannel();
            fic.transferTo(0, fic.size(), foc);
            fic.close();
            foc.close();
            setDestination(Destinations[Index]);
            setPayload(Headers[Index]);
            Index++;
            return true;
        }
        return false;
    }
@Test
    public void testSQLite() {
        log("trying SQLite..");
        for (int i = 0; i < 10; i++) {
            Connection c = null;
            try {
                Class.forName("SQLite.JDBCDriver");
                c = DriverManager.getConnection("jdbc:sqlite:/C:/Source/SRFSurvey/app/src/org/speakright/srfsurvey/results.db", "", "");
                c.setAutoCommit(false);
                Statement st = c.createStatement();
                int rc = st.executeUpdate("INSERT INTO tblAnswers(fQID,fQNAME) VALUES('q1','zoo')");
                st.close();
                c.commit();
                c.close();
            } catch (Exception e) {
                System.err.println(e.getClass().getName() + ": " + e.getMessage());
                System.exit(1);
                try {
                    if (c != null && !c.isClosed()) {
                        c.rollback();
                        c.close();
                    }
                } catch (SQLException sql) {
                }
            }
        }
        log("end");
    }
public static void retriveRemote(ISource source, Node[] nodes, String outDirName, boolean isBinary) throws Exception {
        FTPClient client = new FTPClient();
        client.connect(source.getSourceDetail().getHost());
        client.login(source.getSourceDetail().getUser(), source.getSourceDetail().getPassword());
        if (isBinary) client.setFileType(FTPClient.BINARY_FILE_TYPE);
        FileOutputStream out = null;
        for (Node node : nodes) {
            if (!node.isLeaf()) {
                Node[] childern = source.getChildern(node);
                File dir = new File(outDirName + File.separator + node.getAlias());
                dir.mkdir();
                retriveRemote(source, childern, outDirName + File.separator + node.getAlias(), isBinary);
            } else {
                out = new FileOutputStream(outDirName + File.separator + node.getAlias());
                client.retrieveFile(node.getAbsolutePath(), out);
                out.flush();
                out.close();
            }
        }
        client.disconnect();
    }
public static void storeRemote(String sourceLocation, SourceDetail targetSourceDetail, String targetlocation, boolean isBinary) throws Exception {
        FTPClient client = new FTPClient();
        client.connect(targetSourceDetail.getHost());
        client.login(targetSourceDetail.getUser(), targetSourceDetail.getPassword());
        if (isBinary) client.setFileType(FTPClient.BINARY_FILE_TYPE);
        File file = new File(sourceLocation);
        if (file.isDirectory()) {
            client.makeDirectory(targetlocation);
            FileInputStream in = null;
            for (File myFile : file.listFiles()) {
                if (myFile.isDirectory()) {
                    storeRemote(myFile.getAbsolutePath(), targetSourceDetail, targetlocation + "/" + myFile.getName(), isBinary);
                } else {
                    in = new FileInputStream(myFile.getAbsolutePath());
                    if (!targetlocation.endsWith("/")) client.storeFile(targetlocation + "/" + myFile.getName(), in); else client.storeFile(targetlocation + myFile.getName(), in);
                    in.close();
                }
            }
        } else {
            FileInputStream in = new FileInputStream(sourceLocation);
            client.storeFile(targetlocation, in);
            in.close();
        }
        client.disconnect();
    }
@Override
    protected RequestLogHandler createRequestLogHandler() {
        try {
            File logbackConf = File.createTempFile("logback-access", ".xml");
            IOUtils.copy(Thread.currentThread().getContextClassLoader().getResourceAsStream("logback-access.xml"), new FileOutputStream(logbackConf));
            RequestLogHandler requestLogHandler = new RequestLogHandler();
            RequestLogImpl requestLog = new RequestLogImpl();
            requestLog.setFileName(logbackConf.getPath());
            requestLogHandler.setRequestLog(requestLog);
        } catch (FileNotFoundException e) {
            log.error("Could not create request log handler", e);
        } catch (IOException e) {
            log.error("Could not create request log handler", e);
        }
        return null;
    }
public static String encryptStringWithSHA2(String input) {
        String output = null;
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("SHA-256");
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        md.update(input.getBytes());
        byte byteData[] = md.digest();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < byteData.length; i++) {
            sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
        }
        output = sb.toString();
        return output;
    }
private String createVisadFile(String fileName) throws FileNotFoundException, IOException {
        ArrayList<String> columnNames = new ArrayList<String>();
        String visadFile = fileName + ".visad";
        BufferedReader buf = new BufferedReader(new FileReader(fileName));
        String firstLine = buf.readLine().replace('"', ' ');
        StringTokenizer st = new StringTokenizer(firstLine, ",");
        while (st.hasMoreTokens()) columnNames.add(st.nextToken());
        StringBuilder headerBuilder = new StringBuilder();
        headerBuilder.append("(").append(columnNames.get(0)).append("->(");
        for (int i = 1; i < columnNames.size(); i++) {
            headerBuilder.append(columnNames.get(i));
            if (i < columnNames.size() - 1) headerBuilder.append(",");
        }
        headerBuilder.append("))");
        BufferedWriter out = new BufferedWriter(new FileWriter(visadFile));
        out.write(headerBuilder.toString() + "\n");
        out.write(firstLine + "\n");
        String line;
        while ((line = buf.readLine()) != null) out.write(line + "\n");
        buf.close();
        out.close();
        return visadFile;
    }
public boolean open() {
        if (null == _uu) {
            try {
                if (null == url) return false; else {
                    if (null != this.query) this.url = constructQuery(url, this.query);
                    _uu = url.openConnection();
                    _uu.setAllowUserInteraction(false);
                    _uu.setDoInput(true);
                    if (null != super._loc) {
                        try {
                            _uu.setRequestProperty("Accept-Language", jsGet_locale());
                        } catch (JavaScriptException jsx) {
                        }
                    }
                    encoding = _uu.getContentEncoding();
                    bytesize = _uu.getContentLength();
                    mimetype = _uu.getContentType();
                    serviceDate = _uu.getDate();
                    contentExpires = _uu.getExpiration();
                    contentLastmod = _uu.getLastModified();
                    return true;
                }
            } catch (Exception exc) {
                close();
                return false;
            }
        } else return true;
    }