semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
protected JavaFileObject open(String className) throws IOException {
        JavaFileObject fo = getClassFileObject(className);
        if (fo != null) return fo;
        String cn = className;
        int lastDot;
        while ((lastDot = cn.lastIndexOf(".")) != -1) {
            cn = cn.substring(0, lastDot) + "$" + cn.substring(lastDot + 1);
            fo = getClassFileObject(cn);
            if (fo != null) return fo;
        }
        if (!className.endsWith(".class")) return null;
        if (fileManager instanceof StandardJavaFileManager) {
            StandardJavaFileManager sfm = (StandardJavaFileManager) fileManager;
            fo = sfm.getJavaFileObjects(className).iterator().next();
            if (fo != null && fo.getLastModified() != 0) {
                return fo;
            }
        }
        if (className.matches("^[A-Za-z]+:.*")) {
            try {
                final URI uri = new URI(className);
                final URL url = uri.toURL();
                final URLConnection conn = url.openConnection();
                return new JavaFileObject() {

                    public Kind getKind() {
                        return JavaFileObject.Kind.CLASS;
                    }

                    public boolean isNameCompatible(String simpleName, Kind kind) {
                        throw new UnsupportedOperationException();
                    }

                    public NestingKind getNestingKind() {
                        throw new UnsupportedOperationException();
                    }

                    public Modifier getAccessLevel() {
                        throw new UnsupportedOperationException();
                    }

                    public URI toUri() {
                        return uri;
                    }

                    public String getName() {
                        return url.toString();
                    }

                    public InputStream openInputStream() throws IOException {
                        return conn.getInputStream();
                    }

                    public OutputStream openOutputStream() throws IOException {
                        throw new UnsupportedOperationException();
                    }

                    public Reader openReader(boolean ignoreEncodingErrors) throws IOException {
                        throw new UnsupportedOperationException();
                    }

                    public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException {
                        throw new UnsupportedOperationException();
                    }

                    public Writer openWriter() throws IOException {
                        throw new UnsupportedOperationException();
                    }

                    public long getLastModified() {
                        return conn.getLastModified();
                    }

                    public boolean delete() {
                        throw new UnsupportedOperationException();
                    }
                };
            } catch (URISyntaxException ignore) {
            } catch (IOException ignore) {
            }
        }
        return null;
    }
public char check(String password) {
        if (captchaRandom.equals("null")) {
            return 's';
        }
        if (captchaRandom.equals("used")) {
            return 'm';
        }
        String encryptionBase = secret + captchaRandom;
        if (!alphabet.equals(ALPHABET_DEFAULT) || letters != LETTERS_DEFAULT) {
            encryptionBase += ":" + alphabet + ":" + letters;
        }
        MessageDigest md5;
        byte[] digest = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        try {
            md5 = MessageDigest.getInstance("MD5");
            md5.update(encryptionBase.getBytes());
            digest = md5.digest();
        } catch (NoSuchAlgorithmException e) {
        }
        String correctPassword = "";
        int index;
        for (int i = 0; i < letters; i++) {
            index = (digest[i] + 256) % 256 % alphabet.length();
            correctPassword += alphabet.substring(index, index + 1);
        }
        if (!password.equals(correctPassword)) {
            return 'w';
        } else {
            captchaRandom = "used";
            return 't';
        }
    }
private boolean createFTPConnection() {
        client = new FTPClient();
        System.out.println("Client created");
        try {
            client.connect(this.hostname, this.port);
            System.out.println("Connected: " + this.hostname + ", " + this.port);
            client.login(username, password);
            System.out.println("Logged in: " + this.username + ", " + this.password);
            this.setupActiveFolder();
            return true;
        } catch (IllegalStateException ex) {
            Logger.getLogger(FTPProject.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(FTPProject.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FTPIllegalReplyException ex) {
            Logger.getLogger(FTPProject.class.getName()).log(Level.SEVERE, null, ex);
        } catch (FTPException ex) {
            Logger.getLogger(FTPProject.class.getName()).log(Level.SEVERE, null, ex);
        }
        return false;
    }
public static NSImage getImage(URL url) {
        InputStream in = null;
        try {
            in = url.openStream();
        } catch (IOException e) {
            Log.error(e.getMessage(), e);
        }
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        byte[] buff = new byte[10 * 1024];
        int len;
        try {
            if (in != null) {
                while ((len = in.read(buff)) != -1) {
                    out.write(buff, 0, len);
                }
                in.close();
            }
            out.close();
        } catch (IOException e) {
            Log.error(e.getMessage(), e);
        }
        NSData data = new NSData(out.toByteArray());
        return new NSImage(data);
    }
public void exe2(String[] args) {
        Connection con = null;
        Connection con2 = null;
        Statement stmt = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        ResultSetMetaData rsmd = null;
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
            con = getConnection("mis030dv");
            con2 = getConnection("mis030db");
            con2.setAutoCommit(false);
            stmt = con.createStatement();
            rs = stmt.executeQuery("SELECT * FROM MIS.MAP_PUR0101 WHERE NOT EXISTS (SELECT 1 FROM MIS.RSCMGOOD@MIS030DB@DEVU01 WHERE GOODCD = PUM_CODE OR GOODCD = NEW_PUM_CODE)");
            pstmt = con2.prepareStatement("INSERT INTO MIS.RSCMGOOD ( GOODCD,GOODFLAG,GOODNM,GOODHNGNM,GOODENGNM,GOODSPEC,GOODMODEL,ASETFLAG,LRGCD,MDLCD,SMLCD,EDICD,PRODCMPYCD,CMT,FSTRGSTRID,FSTRGSTDT,LASTUPDTRID,LASTUPDTDT,APPINSTDATA,MNGTFLAG) " + "VALUES ( ?,SUBSTR(?,1,1),?,?,?,?,NULL,'1',substr(?,2,2),substr(?,4,3),NULL,NULL,NULL,'OCS �����빰ǰ','MISASIS',TO_DATE('20111231','YYYYMMDD'),'MISASIS',TO_DATE('20111231','YYYYMMDD'),NULL,'N')");
            int count = 0;
            String goodcd = null;
            String goodnm = null;
            while (rs.next()) {
                count++;
                goodcd = rs.getString("PUM_CODE").toUpperCase();
                goodnm = rs.getString("PUM_HNAME");
                StringUtils.trimWhitespace(goodnm);
                if (goodnm == null || goodnm.equals("")) goodnm = "-";
                pstmt.setString(1, goodcd);
                pstmt.setString(2, goodcd);
                pstmt.setString(3, goodnm);
                pstmt.setString(4, goodnm);
                pstmt.setString(5, rs.getString("PUM_ENAME"));
                pstmt.setString(6, rs.getString("KYUKYEOK"));
                pstmt.setString(7, goodcd);
                pstmt.setString(8, goodcd);
                pstmt.executeUpdate();
                if (count % 100 == 0) System.out.println("Copy Row : " + count);
            }
            System.out.println("Commit Copy Rows : " + count);
            con2.commit();
        } catch (Exception e) {
            try {
                con2.rollback();
            } catch (Exception ee) {
                ee.printStackTrace();
            }
            e.printStackTrace();
        } finally {
            try {
                if (rs != null) rs.close();
                if (stmt != null) stmt.close();
                if (con != null) con.close();
                if (con2 != null) con2.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
private void createCanvas() {
        GraphicalViewer viewer = new ScrollingGraphicalViewer();
        viewer.setRootEditPart(new ScalableRootEditPart());
        viewer.setEditPartFactory(new BlockEditPartFactory());
        viewer.createControl(this);
        viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer));
        ActionRegistry actionRegistry = new ActionRegistry();
        createActions(actionRegistry);
        ContextMenuProvider cmProvider = new BlockContextMenuProvider(viewer, actionRegistry);
        viewer.setContextMenu(cmProvider);
        Block b = new Block();
        b.addChild(new ChartItem());
        viewer.setContents(b);
        PaletteViewer paletteViewer = new PaletteViewer();
        paletteViewer.createControl(this);
    }
ArrayList<String> remoteSampling(IntersectionFile[] intersectionFiles, double[][] points) {
        logger.info("begin REMOTE sampling, number of threads " + intersectConfig.getThreadCount() + ", number of layers=" + intersectionFiles.length + ", number of coordinates=" + points.length);
        ArrayList<String> output = null;
        try {
            long start = System.currentTimeMillis();
            URL url = new URL(intersectConfig.getLayerIndexUrl() + "/intersect/batch");
            URLConnection c = url.openConnection();
            c.setDoOutput(true);
            OutputStreamWriter out = new OutputStreamWriter(c.getOutputStream());
            out.write("fids=");
            for (int i = 0; i < intersectionFiles.length; i++) {
                if (i > 0) {
                    out.write(",");
                }
                out.write(intersectionFiles[i].getFieldId());
            }
            out.write("&points=");
            for (int i = 0; i < points.length; i++) {
                if (i > 0) {
                    out.write(",");
                }
                out.write(String.valueOf(points[i][0]));
                out.write(",");
                out.write(String.valueOf(points[i][1]));
            }
            out.close();
            CSVReader csv = new CSVReader(new InputStreamReader(new GZIPInputStream(c.getInputStream())));
            long mid = System.currentTimeMillis();
            ArrayList<StringBuilder> tmpOutput = new ArrayList<StringBuilder>();
            for (int i = 0; i < intersectionFiles.length; i++) {
                tmpOutput.add(new StringBuilder());
            }
            String[] line;
            int row = 0;
            csv.readNext();
            while ((line = csv.readNext()) != null) {
                for (int i = 2; i < line.length && i - 2 < tmpOutput.size(); i++) {
                    if (row > 0) {
                        tmpOutput.get(i - 2).append("\n");
                    }
                    tmpOutput.get(i - 2).append(line[i]);
                }
                row++;
            }
            csv.close();
            output = new ArrayList<String>();
            for (int i = 0; i < tmpOutput.size(); i++) {
                output.add(tmpOutput.get(i).toString());
                tmpOutput.set(i, null);
            }
            long end = System.currentTimeMillis();
            logger.info("sample time for " + 5 + " layers and " + 3 + " coordinates: get response=" + (mid - start) + "ms, write response=" + (end - mid) + "ms");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return output;
    }
private void doLogin(String password) throws LoginFailedException, IncorrectPasswordException {
        final long mgr = Constants.MANAGER;
        Data data, response;
        try {
            response = sendAndWait(new Request(mgr)).get(0);
            MessageDigest md;
            try {
                md = MessageDigest.getInstance("MD5");
            } catch (NoSuchAlgorithmException e) {
                throw new RuntimeException("MD5 hash not supported.");
            }
            byte[] challenge = response.getBytes();
            md.update(challenge);
            md.update(password.getBytes(Data.STRING_ENCODING));
            try {
                data = Data.valueOf(md.digest());
                response = sendAndWait(new Request(mgr).add(0, data)).get(0);
            } catch (ExecutionException ex) {
                throw new IncorrectPasswordException();
            }
            setLoginMessage(response.getString());
            response = sendAndWait(new Request(mgr).add(0, getLoginData())).get(0);
            ID = response.getWord();
            registerSettings();
        } catch (InterruptedException ex) {
            throw new LoginFailedException(ex);
        } catch (ExecutionException ex) {
            throw new LoginFailedException(ex);
        } catch (IOException ex) {
            throw new LoginFailedException(ex);
        }
    }
public BigInteger generateHashing(String value, int lengthBits) {
        try {
            MessageDigest algorithm = MessageDigest.getInstance(this.algorithm);
            algorithm.update(value.getBytes());
            byte[] digest = algorithm.digest();
            BigInteger hashing = new BigInteger(+1, digest);
            if (lengthBits != digest.length * 8) {
                BigInteger length = new BigInteger("2");
                length = length.pow(lengthBits);
                hashing = hashing.mod(length);
            }
            return hashing;
        } catch (NoSuchAlgorithmException e) {
            throw new IllegalArgumentException("Error with algorithm", e);
        }
    }
public void delete(Connection conn, boolean commit) throws SQLException {
        PreparedStatement stmt = null;
        if (isNew()) {
            String errorMessage = "Unable to delete non-persistent DAO '" + getClass().getName() + "'";
            if (log.isErrorEnabled()) {
                log.error(errorMessage);
            }
            throw new SQLException(errorMessage);
        }
        try {
            stmt = conn.prepareStatement(getDeleteSql());
            stmt.setObject(1, getPrimaryKey());
            int rowCount = stmt.executeUpdate();
            if (rowCount != 1) {
                if (commit) {
                    conn.rollback();
                }
                String errorMessage = "Invalid number of rows changed!";
                if (log.isErrorEnabled()) {
                    log.error(errorMessage);
                }
                throw new SQLException(errorMessage);
            } else if (commit) {
                conn.commit();
            }
        } finally {
            OvJdbcUtils.closeStatement(stmt);
        }
    }
public void save(Connection conn, boolean commit) throws SQLException {
        PreparedStatement stmt = null;
        if (!isValid()) {
            String errorMessage = "Unable to save invalid DAO '" + getClass().getName() + "'!";
            if (log.isErrorEnabled()) {
                log.error(errorMessage);
            }
            throw new SQLException(errorMessage);
        }
        try {
            if (isNew()) {
                primaryKey = createNewPrimaryKey();
                stmt = conn.prepareStatement(getInsertSql());
            } else {
                stmt = conn.prepareStatement(getUpdateSql());
            }
            setValues(stmt);
            int rowCount = stmt.executeUpdate();
            if (rowCount != 1) {
                primaryKey = OvUuid.NULL_UUID;
                if (commit) {
                    conn.rollback();
                }
                String errorMessage = "Invalid number of rows changed!";
                if (log.isErrorEnabled()) {
                    log.error(errorMessage);
                }
                throw new SQLException(errorMessage);
            } else {
                if (commit) {
                    conn.commit();
                }
            }
        } finally {
            OvJdbcUtils.closeStatement(stmt);
        }
    }
public void run(IProgressMonitor runnerMonitor) throws CoreException {
                try {
                    Map<String, File> projectFiles = new HashMap<String, File>();
                    IPath basePath = new Path("/");
                    for (File nextLocation : filesToZip) {
                        projectFiles.putAll(getFilesToZip(nextLocation, basePath, fileFilter));
                    }
                    if (projectFiles.isEmpty()) {
                        PlatformActivator.logDebug("Zip file (" + zipFileName + ") not created because there were no files to zip");
                        return;
                    }
                    IPath resultsPath = PlatformActivator.getDefault().getResultsPath();
                    File copyRoot = resultsPath.toFile();
                    copyRoot.mkdirs();
                    IPath zipFilePath = resultsPath.append(new Path(finalZip));
                    String zipFileName = zipFilePath.toPortableString();
                    ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFileName));
                    try {
                        out.setLevel(Deflater.DEFAULT_COMPRESSION);
                        for (String filePath : projectFiles.keySet()) {
                            File nextFile = projectFiles.get(filePath);
                            FileInputStream fin = new FileInputStream(nextFile);
                            try {
                                out.putNextEntry(new ZipEntry(filePath));
                                try {
                                    byte[] bin = new byte[4096];
                                    int bread = fin.read(bin, 0, 4096);
                                    while (bread != -1) {
                                        out.write(bin, 0, bread);
                                        bread = fin.read(bin, 0, 4096);
                                    }
                                } finally {
                                    out.closeEntry();
                                }
                            } finally {
                                fin.close();
                            }
                        }
                    } finally {
                        out.close();
                    }
                } catch (FileNotFoundException e) {
                    Status error = new Status(Status.ERROR, PlatformActivator.PLUGIN_ID, Status.ERROR, e.getLocalizedMessage(), e);
                    throw new CoreException(error);
                } catch (IOException e) {
                    Status error = new Status(Status.ERROR, PlatformActivator.PLUGIN_ID, Status.ERROR, e.getLocalizedMessage(), e);
                    throw new CoreException(error);
                }
            }
private static String hashPassword(String password) {
        try {
            String hashword = null;
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(password.getBytes());
            BigInteger hash = new BigInteger(1, md5.digest());
            hashword = hash.toString(16);
            return hashword;
        } catch (NoSuchAlgorithmException ex) {
            throw new RuntimeException(ex);
        }
    }
protected boolean loadJarLibrary(final String jarLib) {
        final String tempLib = System.getProperty("java.io.tmpdir") + File.separator + jarLib;
        boolean copied = IOUtils.copyFile(jarLib, tempLib);
        if (!copied) {
            return false;
        }
        System.load(tempLib);
        return true;
    }
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UsuarioBll usuarioBll = new UsuarioBll();
        String senha = "";
        try {
            MessageDigest messageDigest = MessageDigest.getInstance("MD5");
            messageDigest.update(request.getParameter("Senha").getBytes(), 0, request.getParameter("Senha").length());
            senha = new BigInteger(1, messageDigest.digest()).toString(16);
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        String[] data = request.getParameter("Nascimento").split("/");
        Calendar calendar = Calendar.getInstance();
        calendar.set(Integer.parseInt(data[2]), Integer.parseInt(data[1]) - 1, Integer.parseInt(data[0]));
        Telefone telefone = new Telefone();
        Usuario usuario = new Usuario();
        usuario.setNome(request.getParameter("Nome"));
        telefone.setTelefone(request.getParameter("Telefone").replaceAll("\\D", ""));
        telefone.setTelefoneTipo(TelefoneTipoBll.getTelefoneTipoByTelefoneTipoID(Integer.parseInt(request.getParameter("TipoTelefone"))));
        usuario.setTelefone(telefone);
        usuario.setEmail(request.getParameter("Email"));
        usuario.setCpf(request.getParameter("CPF").replaceAll("\\D", ""));
        usuario.setNascimento(calendar);
        Endereco endereco = new Endereco();
        endereco.setCep(Integer.parseInt(request.getParameter("CEP").replaceAll("\\D", "")));
        endereco.setNumero(request.getParameter("Numero"));
        endereco.setComplemento(request.getParameter("Complemento"));
        usuario.setEndereco(endereco);
        usuario.setSenha(senha);
        String msg = "?msg=0";
        if (usuarioBll.addNewUsuario(usuario)) {
            msg = "?msg=1";
            Usuario usuarioAutenticado = UsuarioBll.getUsuarioByEmailAndSenha(usuario.getEmail(), usuario.getSenha());
            HttpSession session = request.getSession();
            session.setAttribute("usuario", usuarioAutenticado);
        }
        response.sendRedirect("templates/verde-rosa/cadastro.jsp" + msg);
    }
@Override
            public InputStream getInputStream() {
                try {
                    String url = webBrowserObject.resourcePath;
                    File file = Utils.getLocalFile(url);
                    if (file != null) {
                        url = webBrowserObject.getLocalFileURL(file);
                    }
                    url = url.substring(0, url.lastIndexOf('/')) + "/" + resource;
                    return new URL(url).openStream();
                } catch (Exception e) {
                }
                return null;
            }