semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public static void main(String arg[]) {
        try {
            URL url = new URL(tempurl);
            HttpURLConnection connect = (HttpURLConnection) url.openConnection();
            connect.setDoInput(true);
            connect.setDoOutput(true);
            BufferedReader in = new BufferedReader(new InputStreamReader(connect.getInputStream(), "gb2312"));
            String line = null;
            StringBuffer content = new StringBuffer();
            while ((line = in.readLine()) != null) {
                content.append(line);
            }
            in.close();
            url = null;
            String msg = content.toString();
            Matcher m = p.matcher(msg);
            while (m.find()) {
                System.out.println(m.group(1) + "---" + m.group(2) + "---" + m.group(3) + "---" + m.group(4) + "---" + m.group(5) + "---");
            }
        } catch (Exception e) {
            System.out.println("Error:");
            System.out.println(e.getStackTrace());
        }
    }
private void initializeSecretKey() {
        String baseKey = "" + SystemClock.currentThreadTimeMillis() + new Random().nextInt();
        MessageDigest digest;
        String secretKey;
        try {
            digest = java.security.MessageDigest.getInstance("MD5");
            digest.reset();
            digest.update(baseKey.getBytes());
            byte messageDigest[] = digest.digest();
            int len = messageDigest.length;
            StringBuilder sb = new StringBuilder(len << 1);
            for (int i = 0; i < len; i++) {
                sb.append(Character.forDigit((messageDigest[i] & 0xf0) >> 4, 16));
                sb.append(Character.forDigit(messageDigest[i] & 0x0f, 16));
            }
            secretKey = sb.substring(0, 32);
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        }
        this.setSecretKey(secretKey);
    }
public int executar(String sql, Boolean retornaAutoIncremento) {
        int autoIncremento = 0;
        try {
            for (Connection conn : conexoes) {
                stm = conn.createStatement();
                stm.executeUpdate(sql);
            }
            for (Connection conn : conexoes) {
                conn.commit();
            }
        } catch (Exception ex) {
            try {
                for (Connection conn : conexoes) {
                    conn.rollback();
                }
                return 0;
            } catch (SQLException Sqlex) {
                Logger.getLogger(Persistencia.class.getName()).log(Level.SEVERE, null, Sqlex);
            }
        }
        if (retornaAutoIncremento) autoIncremento = getUltimoIdentificador();
        return autoIncremento;
    }
public String uploadZtree(ArrayList c) {
        try {
            String id = generateRandomId();
            Iterator iter = c.iterator();
            URL url = new URL(ZorobotSystem.props.getProperty("zoro.url") + "auplo1.jsp");
            URLConnection connection = url.openConnection();
            connection.setDoOutput(true);
            PrintWriter out = new PrintWriter(connection.getOutputStream());
            out.print("id=" + id + "&");
            StringBuffer sb = new StringBuffer();
            int gg = 0;
            while (iter.hasNext()) {
                if (gg++ >= 500) break;
                String st = (String) iter.next();
                sb.append("a=");
                sb.append(URLEncoder.encode(st, "UTF-8"));
                if (iter.hasNext() && gg < 500) sb.append("&");
            }
            out.println(sb.toString());
            out.close();
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String inputLine;
            if ((inputLine = in.readLine()) != null) {
                if (!inputLine.equals("OK!") && inputLine.length() > 3) {
                    System.out.println("Not OK: " + inputLine);
                    return "xxxxxxxxxx";
                }
            }
            in.close();
            return id;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
@Test
    public void pk() throws Exception {
        Connection conn = s.getConnection();
        conn.setAutoCommit(false);
        PreparedStatement ps = conn.prepareStatement("insert into t_test(t_name,t_cname,t_data,t_date,t_double) values(?,?,?,?,?)");
        for (int i = 10; i < 20; ++i) {
            ps.setString(1, "name-" + i);
            ps.setString(2, "cname-" + i);
            ps.setBlob(3, null);
            ps.setTimestamp(4, new Timestamp(System.currentTimeMillis()));
            ps.setNull(5, java.sql.Types.DOUBLE);
            ps.executeUpdate();
        }
        conn.rollback();
        conn.setAutoCommit(true);
        ps.close();
        conn.close();
    }
@Override
    public int deleteStatement(String sql) {
        Statement statement = null;
        try {
            statement = getConnection().createStatement();
            int result = statement.executeUpdate(sql.toString());
            if (result == 0) log.warn(sql + " result row count is 0");
            getConnection().commit();
            return result;
        } catch (SQLException e) {
            try {
                getConnection().rollback();
            } catch (SQLException e1) {
                log.error(e1.getMessage(), e1);
            }
            log.error(e.getMessage(), e);
            throw new RuntimeException();
        } finally {
            try {
                statement.close();
                getConnection().close();
            } catch (SQLException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
@Override
    public long insertStatement(String sql) {
        Statement statement = null;
        try {
            statement = getConnection().createStatement();
            long result = statement.executeUpdate(sql.toString());
            if (result == 0) log.warn(sql + " result row count is 0");
            getConnection().commit();
            return getInsertId(statement);
        } catch (SQLException e) {
            try {
                getConnection().rollback();
            } catch (SQLException e1) {
                log.error(e1.getMessage(), e1);
            }
            log.error(e.getMessage(), e);
            throw new RuntimeException();
        } finally {
            try {
                statement.close();
                getConnection().close();
            } catch (SQLException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
@Override
    public int updateStatement(String sql) {
        Statement statement = null;
        try {
            statement = getConnection().createStatement();
            return statement.executeUpdate(sql);
        } catch (SQLException e) {
            try {
                getConnection().rollback();
            } catch (SQLException e1) {
                log.error(e1.getMessage(), e1);
            }
            log.error(e.getMessage(), e);
            return 0;
        } finally {
            try {
                statement.close();
                getConnection().close();
            } catch (SQLException e) {
                log.error(e.getMessage(), e);
            }
        }
    }
public static void copy(File source, File destination) throws FileNotFoundException, IOException {
        if (source == null) throw new NullPointerException("The source may not be null.");
        if (destination == null) throw new NullPointerException("The destination may not be null.");
        FileInputStream sourceStream = new FileInputStream(source);
        destination.getParentFile().mkdirs();
        FileOutputStream destStream = new FileOutputStream(destination);
        try {
            FileChannel sourceChannel = sourceStream.getChannel();
            FileChannel destChannel = destStream.getChannel();
            destChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
        } finally {
            try {
                sourceStream.close();
                destStream.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
public static String encryptPassword(String password) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA");
            md.update(password.getBytes());
            byte[] hash = md.digest();
            StringBuffer hashStringBuf = new StringBuffer();
            String byteString;
            int byteLength;
            for (int index = 0; index < hash.length; index++) {
                byteString = String.valueOf(hash[index] + 128);
                byteLength = byteString.length();
                switch(byteLength) {
                    case 1:
                        byteString = "00" + byteString;
                        break;
                    case 2:
                        byteString = "0" + byteString;
                        break;
                }
                hashStringBuf.append(byteString);
            }
            return hashStringBuf.toString();
        } catch (NoSuchAlgorithmException nsae) {
            log.error("Error getting password hash - " + nsae.getMessage());
            return null;
        }
    }
public void addURL(String urlSpec) throws IOException {
        URL url = new URL(urlSpec);
        for (int i = 0; i < urls.size(); i++) {
            if (((URL) urls.elementAt(i)).equals(url)) {
                Logger.logWarning("Attempt to add an URL twice: " + url);
                return;
            }
        }
        InputStream stream = url.openStream();
        stream.close();
        urls.addElement(urlSpec);
        Logger.logDebug("Added " + url);
    }
public void update() {
        Vector invalids = new Vector();
        for (int i = 0; i < urls.size(); i++) {
            URL url = null;
            try {
                url = new URL((String) urls.elementAt(i));
                InputStream stream = url.openStream();
                stream.close();
            } catch (MalformedURLException urlE) {
                Logger.logWarning("Malformed URL: " + urls.elementAt(i));
            } catch (IOException ioE) {
                invalids.addElement(url);
            }
        }
        for (int i = 0; i < invalids.size(); i++) {
            urls.removeElement(invalids.elementAt(i));
            Logger.logInfo("Removed " + invalids.elementAt(i) + " - no longer available");
        }
    }
public synchronized String encrypt(String plaintext) throws Exception {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            throw e;
        }
        try {
            md.update(plaintext.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw e;
        }
        byte raw[] = md.digest();
        String hash = (new BASE64Encoder()).encode(raw);
        return hash;
    }
public static boolean copyFile(final File fileFrom, final File fileTo) {
        assert fileFrom != null : "fileFrom is null";
        assert fileTo != null : "fileTo is null";
        LOGGER.info(buildLogString(COPY_FILE_INFO, new Object[] { fileFrom, fileTo }));
        boolean error = true;
        FileInputStream inputStream = null;
        FileOutputStream outputStream = null;
        try {
            inputStream = new FileInputStream(fileFrom);
            outputStream = new FileOutputStream(fileTo);
            final FileChannel inChannel = inputStream.getChannel();
            final FileChannel outChannel = outputStream.getChannel();
            inChannel.transferTo(0, inChannel.size(), outChannel);
            error = false;
        } catch (final IOException e) {
            LOGGER.log(SEVERE, buildLogString(COPY_FILE_ERROR, new Object[] { fileFrom, fileTo }), e);
        } finally {
            closeCloseable(inputStream, fileFrom);
            closeCloseable(outputStream, fileTo);
        }
        return error;
    }
public static void home4www(String location) throws NetworkException {
        HttpClient client = HttpUtil.newInstance();
        HttpGet get = new HttpGet(HttpUtil.KAIXIN_WWW_URL + location);
        HttpUtil.setHeader(get);
        try {
            HttpResponse response = client.execute(get);
            HTTPUtil.consume(response.getEntity());
        } catch (Exception e) {
            e.printStackTrace();
            throw new NetworkException(e);
        }
    }
public static void logout(String verify) throws NetworkException {
        HttpClient client = HttpUtil.newInstance();
        HttpGet get = new HttpGet(HttpUtil.KAIXIN_LOGOUT_URL + HttpUtil.KAIXIN_PARAM_VERIFY + verify);
        HttpUtil.setHeader(get);
        try {
            HttpResponse response = client.execute(get);
            if (response != null && response.getEntity() != null) {
                HTTPUtil.consume(response.getEntity());
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new NetworkException(e);
        }
    }
public static void logout4www() throws NetworkException {
        HttpClient client = HttpUtil.newInstance();
        HttpGet get = new HttpGet(HttpUtil.KAIXIN_WWW_LOGOUT_URL);
        HttpUtil.setHeader(get);
        try {
            HttpResponse response = client.execute(get);
            if (response != null && response.getEntity() != null) {
                HTTPUtil.consume(response.getEntity());
            }
        } catch (Exception e) {
            e.printStackTrace();
            throw new NetworkException(e);
        }
    }
public static String getMD5(String str) {
        MessageDigest md5;
        try {
            md5 = MessageDigest.getInstance("MD5");
            md5.update(str.getBytes());
            String pwd = new BigInteger(1, md5.digest()).toString(16);
            return pwd;
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
        return str;
    }
private ResourceZoneRulesDataProvider(URL url) throws ClassNotFoundException, IOException {
        boolean throwing = false;
        InputStream in = null;
        try {
            in = url.openStream();
            DataInputStream dis = new DataInputStream(in);
            if (dis.readByte() != 1) {
                throw new StreamCorruptedException("File format not recognised");
            }
            this.groupID = dis.readUTF();
            int versionCount = dis.readShort();
            String[] versionArray = new String[versionCount];
            for (int i = 0; i < versionCount; i++) {
                versionArray[i] = dis.readUTF();
            }
            int regionCount = dis.readShort();
            String[] regionArray = new String[regionCount];
            for (int i = 0; i < regionCount; i++) {
                regionArray[i] = dis.readUTF();
            }
            this.regions = new HashSet<String>(Arrays.asList(regionArray));
            Set<ZoneRulesVersion> versionSet = new HashSet<ZoneRulesVersion>(versionCount);
            for (int i = 0; i < versionCount; i++) {
                int versionRegionCount = dis.readShort();
                String[] versionRegionArray = new String[versionRegionCount];
                short[] versionRulesArray = new short[versionRegionCount];
                for (int j = 0; j < versionRegionCount; j++) {
                    versionRegionArray[j] = regionArray[dis.readShort()];
                    versionRulesArray[j] = dis.readShort();
                }
                versionSet.add(new ResourceZoneRulesVersion(this, versionArray[i], versionRegionArray, versionRulesArray));
            }
            this.versions = versionSet;
            int ruleCount = dis.readShort();
            this.rules = new AtomicReferenceArray<Object>(ruleCount);
            for (int i = 0; i < ruleCount; i++) {
                byte[] bytes = new byte[dis.readShort()];
                dis.readFully(bytes);
                rules.set(i, bytes);
            }
        } catch (IOException ex) {
            throwing = true;
            throw ex;
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException ex) {
                    if (throwing == false) {
                        throw ex;
                    }
                }
            }
        }
    }
public void login(String UID, String PWD, int CTY) throws Exception {
        sSideURL = sSideURLCollection[CTY];
        sUID = UID;
        sPWD = PWD;
        iCTY = CTY;
        sLoginLabel = getLoginLabel(sSideURL);
        String sParams = getLoginParams();
        CookieHandler.setDefault(new ListCookieHandler());
        URL url = new URL(sSideURL + sLoginURL);
        URLConnection conn = url.openConnection();
        setRequestProperties(conn);
        conn.setDoInput(true);
        conn.setDoOutput(true);
        OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
        wr.write(sParams);
        wr.flush();
        BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
        StringBuilder sb = new StringBuilder();
        String line = rd.readLine();
        while (line != null) {
            sb.append(line + "\n");
            line = rd.readLine();
        }
        wr.close();
        rd.close();
        String sPage = sb.toString();
        Pattern p = Pattern.compile(">Dein Penner<");
        Matcher matcher = p.matcher(sPage);
        LogedIn = matcher.find();
    }
public RecordIterator(URL fileUrl, ModelDataFile modelDataFile) throws DataFileException {
        this.modelDataFile = modelDataFile;
        InputStream urlStream = null;
        try {
            urlStream = fileUrl.openStream();
        } catch (IOException e) {
            throw new DataFileException("Error open URL: " + fileUrl.toString(), e);
        }
        this.setupStream(urlStream, fileUrl.toString());
    }
private boolean _copyPath(String source, String destination, Object handler) {
        try {
            FileInputStream fis = new FileInputStream(_fullPathForPath(source));
            FileOutputStream fos = new FileOutputStream(_fullPathForPath(destination));
            byte[] buffer = new byte[fis.available()];
            int read;
            for (read = fis.read(buffer); read >= 0; read = fis.read(buffer)) {
                fos.write(buffer, 0, read);
            }
            fis.close();
            fos.close();
            return true;
        } catch (IOException ioe) {
            ioe.printStackTrace();
            return false;
        }
    }
@SuppressWarnings("unchecked")
    public static void main(String[] args) throws Exception {
        if (args.length != 2) {
            System.out.println("usage: " + EvaluatorHelper.class.getName() + " <output> <data set file>");
            System.exit(1);
        }
        Helper helper = Helper.getHelper(args[1]);
        Dataset dataset = helper.read(args[1]);
        ZipFile zip = new ZipFile(new File(args[0]), ZipFile.OPEN_READ);
        Enumeration entries = zip.entries();
        Unit<?>[] performance = new Unit<?>[LIMIT];
        int index = 0;
        while (entries.hasMoreElements()) {
            ZipEntry entry = (ZipEntry) entries.nextElement();
            if (entry.getName().endsWith(".out")) {
                File temp = File.createTempFile("PARSER", ".zip");
                temp.deleteOnExit();
                PrintStream writer = new PrintStream(new FileOutputStream(temp));
                BufferedInputStream reader = new BufferedInputStream(zip.getInputStream(entry));
                byte[] buffer = new byte[4096];
                int read = -1;
                while ((read = reader.read(buffer)) != -1) {
                    writer.write(buffer, 0, read);
                }
                writer.close();
                reader.close();
                BufferedReader outfile = new BufferedReader(new FileReader(temp));
                String line = null;
                RuleParser parser = new RuleParser();
                ProbabilisticRuleList list = new ProbabilisticRuleList();
                while ((line = outfile.readLine()) != null) {
                    if (line.startsWith("IF")) {
                        ProbabilisticRule rule = new ProbabilisticRule(dataset.getMetadata());
                        list.add(fill(dataset.getMetadata(), rule, parser.parse(line)));
                    }
                }
                outfile.close();
                PooledPRCurveMeasure measure = new PooledPRCurveMeasure();
                performance[index] = measure.evaluate(dataset, list);
                System.out.println(entry.getName() + ": " + performance[index]);
                index++;
                if (index >= LIMIT) {
                    break;
                }
            }
        }
        System.out.println(UnitAveragingMode.get(Double.class).average(performance));
    }
public static String validateSession(String sessionid, String servicekey, HttpServletRequest request) {
        if (sessionid == null) {
            return "error";
        }
        String loginapp = SSOFilter.getLoginapp();
        String u = SSOUtil.addParameter(loginapp + "/api/validatesessionid", "sessionid", sessionid);
        u = SSOUtil.addParameter(u, "servicekey", servicekey);
        u = SSOUtil.addParameter(u, "ip", request.getRemoteHost());
        u = SSOUtil.addParameter(u, "url", encodeUrl(request.getRequestURI()));
        u = SSOUtil.addParameter(u, "useragent", request.getHeader("User-Agent"));
        String response = "error";
        try {
            URL url = new URL(u);
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
            String line;
            while ((line = reader.readLine()) != null) {
                response = line.trim();
            }
            reader.close();
        } catch (MalformedURLException e) {
        } catch (IOException e) {
        }
        if ("error".equals(response)) {
            return "error";
        } else {
            return response;
        }
    }
public static String callApi(String api, String paramname, String paramvalue) {
        String loginapp = SSOFilter.getLoginapp();
        String u = SSOUtil.addParameter(loginapp + "/api/" + api, paramname, paramvalue);
        u = SSOUtil.addParameter(u, "servicekey", SSOFilter.getServicekey());
        String response = "error";
        try {
            URL url = new URL(u);
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
            String line;
            while ((line = reader.readLine()) != null) {
                response = line.trim();
            }
            reader.close();
        } catch (MalformedURLException e) {
        } catch (IOException e) {
        }
        if ("error".equals(response)) {
            return "error";
        } else {
            return response;
        }
    }
public static String validateAuthTicketAndGetSessionId(ServletRequest request, String servicekey) {
        String loginapp = SSOFilter.getLoginapp();
        String authticket = request.getParameter("authticket");
        String u = SSOUtil.addParameter(loginapp + "/api/validateauthticket", "authticket", authticket);
        u = SSOUtil.addParameter(u, "servicekey", servicekey);
        String sessionid = null;
        try {
            URL url = new URL(u);
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
            String line;
            while ((line = reader.readLine()) != null) {
                sessionid = line.trim();
            }
            reader.close();
        } catch (MalformedURLException e) {
            return null;
        } catch (IOException e) {
            return null;
        }
        if ("error".equals(sessionid)) {
            return null;
        }
        return sessionid;
    }