semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
@SuppressWarnings("unchecked")
    private ReaderFeed processEntrys(String urlStr, String currentFlag) throws UnsupportedEncodingException, IOException, JDOMException {
        String key = "processEntrys@" + urlStr + "_" + currentFlag;
        if (cache.containsKey(key)) {
            return (ReaderFeed) cache.get(key);
        }
        List<Post> postList = new ArrayList<Post>();
        URL url = new URL(urlStr);
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        connection.setRequestMethod("GET");
        connection.setRequestProperty("Cookie", "SID=" + sid);
        BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), "UTF-8"));
        SAXBuilder builder = new SAXBuilder(false);
        Document doc = builder.build(reader);
        Element root = doc.getRootElement();
        Namespace grNamespace = root.getNamespace("gr");
        Namespace namespace = root.getNamespace();
        String newflag = root.getChildText("continuation", grNamespace);
        String title = root.getChildText("title", namespace);
        String subTitle = root.getChildText("subtitle", namespace);
        List<Element> entryList = root.getChildren("entry", namespace);
        DateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'");
        for (Element e : entryList) {
            Post post = new Post();
            post.setTitle(e.getChildText("title", namespace));
            try {
                post.setDate(sdf.parse(e.getChildText("published", namespace)));
            } catch (ParseException e1) {
            }
            post.setUrl(e.getChild("link", namespace).getAttributeValue("href"));
            post.setSauthor(e.getChild("author", namespace).getChildText("name", namespace));
            String content = e.getChildText("content", namespace);
            if (StringUtils.isEmpty(content)) {
                content = e.getChildText("description", namespace);
            }
            if (StringUtils.isEmpty(content)) {
                content = e.getChildText("summary", namespace);
            }
            post.setContent(content);
            postList.add(post);
        }
        ReaderFeed readerFeed = new ReaderFeed();
        readerFeed.setTitle(title);
        readerFeed.setSubTitle(subTitle);
        readerFeed.setFlag(newflag);
        readerFeed.setPostList(postList);
        cache.put(key, readerFeed);
        return readerFeed;
    }
protected void setUp() throws Exception {
        super.setUp();
        bundles = Activator.bundleContext.getBundles();
        for (int i = 0; i < bundles.length; ++i) {
            if (bundles[i] != null) {
                if ((bundles[i].getSymbolicName() == null) || (!bundles[i].getSymbolicName().startsWith(PSS))) {
                    bundles[i] = null;
                }
            }
        }
        checklist = new Properties();
        try {
            URL url = Activator.bundleContext.getBundle().getResource(CHECK_FILE);
            InputStream is = new BufferedInputStream(url.openStream());
            checklist.load(is);
            is.close();
        } catch (FileNotFoundException fe) {
            fail("Failed to find service checklist file");
        } catch (IOException e) {
            fail("Failed to load service checklist file");
        }
        if (pssTracker == null) {
            pssTracker = new ServiceTracker(Activator.bundleContext, IPssManager.class.getName(), null);
        }
        pssTracker.open();
    }
public void reset(String componentName, int currentPilot) {
        try {
            PreparedStatement psta = jdbc.prepareStatement("DELETE FROM component_prop " + "WHERE pilot_id = ? " + "AND component_name = ?");
            psta.setInt(1, currentPilot);
            psta.setString(2, componentName);
            psta.executeUpdate();
            jdbc.commit();
        } catch (SQLException e) {
            jdbc.rollback();
            log.debug(e);
        }
    }
public void reset(int currentPilot) {
        try {
            PreparedStatement psta = jdbc.prepareStatement("DELETE FROM component_prop " + "WHERE pilot_id = ? ");
            psta.setInt(1, currentPilot);
            psta.executeUpdate();
            jdbc.commit();
        } catch (SQLException e) {
            jdbc.rollback();
            log.debug(e);
        }
    }
public void writeBack(File destinationFile, boolean makeCopy) throws IOException {
        if (makeCopy) {
            FileChannel sourceChannel = new java.io.FileInputStream(getFile()).getChannel();
            FileChannel destinationChannel = new java.io.FileOutputStream(destinationFile).getChannel();
            sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
            sourceChannel.close();
            destinationChannel.close();
        } else {
            getFile().renameTo(destinationFile);
        }
        if (getExifTime() != null && getOriginalTime() != null && !getExifTime().equals(getOriginalTime())) {
            String adjustArgument = "-ts" + m_dfJhead.format(getExifTime());
            ProcessBuilder pb = new ProcessBuilder(m_tm.getJheadCommand(), adjustArgument, destinationFile.getAbsolutePath());
            pb.directory(destinationFile.getParentFile());
            System.out.println(pb.command().get(0) + " " + pb.command().get(1) + " " + pb.command().get(2));
            final Process p = pb.start();
            try {
                p.waitFor();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
public SparqlQueryLoaderImpl() throws IOException {
        ClassLoader loader = SparqlQueryLoaderImpl.class.getClassLoader();
        URL url = loader.getResource(PROPERTIES_FILENAME);
        InputStream stream = url.openStream();
        properties.load(stream);
        stream.close();
        String names = getProperties().getProperty(NAMES_PARAMETER);
        StringTokenizer st = new StringTokenizer(names, ",");
        while (st.hasMoreTokens()) {
            String name = st.nextToken();
            String value = readContents(String.format("sparql/%s.sparql", name));
            getName2Query().put(name, value);
        }
    }
public static void copy(String fileFrom, String fileTo) throws IOException {
        FileInputStream inputStream = null;
        FileOutputStream outputStream = null;
        FileChannel inputChannel = null;
        FileChannel outputChannel = null;
        try {
            inputStream = new FileInputStream(fileFrom);
            outputStream = new FileOutputStream(fileTo);
            inputChannel = inputStream.getChannel();
            outputChannel = outputStream.getChannel();
            inputChannel.transferTo(0, inputChannel.size(), outputChannel);
        } finally {
            try {
                inputChannel.close();
            } finally {
                try {
                    outputChannel.close();
                } finally {
                    try {
                        inputStream.close();
                    } finally {
                        outputStream.close();
                    }
                }
            }
        }
    }
private ByteBuffer getByteBuffer(String resource) throws IOException {
        ClassLoader classLoader = this.getClass().getClassLoader();
        InputStream in = classLoader.getResourceAsStream(resource);
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        IOUtils.copy(in, out);
        return ByteBuffer.wrap(out.toByteArray());
    }
public static SOAPMessage call(SOAPMessage request, URL url) throws IOException, SOAPException {
        URLConnection conn = url.openConnection();
        conn.setDoOutput(true);
        conn.setDoInput(true);
        conn.connect();
        request.writeTo(conn.getOutputStream());
        MessageFactory mf = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
        return mf.createMessage(null, conn.getInputStream());
    }
private static void copyFile(final File sourceFile, final File destFile) throws IOException {
        if (!destFile.exists()) {
            if (!destFile.createNewFile()) {
                throw new IOException("Destination file cannot be created: " + destFile.getPath());
            }
        }
        FileChannel source = null;
        FileChannel destination = null;
        try {
            source = new FileInputStream(sourceFile).getChannel();
            destination = new FileOutputStream(destFile).getChannel();
            destination.transferFrom(source, 0, source.size());
        } finally {
            if (source != null) {
                source.close();
            }
            if (destination != null) {
                destination.close();
            }
        }
    }
public static String encrypt(String text) {
        char[] toEncrypt = text.toCharArray();
        StringBuffer hexString = new StringBuffer();
        try {
            MessageDigest dig = MessageDigest.getInstance("MD5");
            dig.reset();
            String pw = "";
            for (int i = 0; i < toEncrypt.length; i++) {
                pw += toEncrypt[i];
            }
            dig.update(pw.getBytes());
            byte[] digest = dig.digest();
            int digestLength = digest.length;
            for (int i = 0; i < digestLength; i++) {
                hexString.append(hexDigit(digest[i]));
            }
        } catch (java.security.NoSuchAlgorithmException ae) {
            ae.printStackTrace();
        }
        return hexString.toString();
    }
public static void copyCompletely(InputStream input, OutputStream output) throws IOException {
        if ((output instanceof FileOutputStream) && (input instanceof FileInputStream)) {
            try {
                FileChannel target = ((FileOutputStream) output).getChannel();
                FileChannel source = ((FileInputStream) input).getChannel();
                source.transferTo(0, Integer.MAX_VALUE, target);
                source.close();
                target.close();
                return;
            } catch (Exception e) {
            }
        }
        byte[] buf = new byte[8192];
        while (true) {
            int length = input.read(buf);
            if (length < 0) break;
            output.write(buf, 0, length);
        }
        try {
            input.close();
        } catch (IOException ignore) {
        }
        try {
            output.close();
        } catch (IOException ignore) {
        }
    }
public void run() {
        btnReintentar.setEnabled(false);
        try {
            lblEstado.setText("Conectando con servidor...");
            escribir("\nConectando con servidor...");
            URL url = new URL("http://apeiron.sourceforge.net/version.php");
            lblEstado.setText("Obteniendo informaci�n de versi�n...");
            escribir("Ok\n");
            escribir("Obteniendo informaci�n sobre �ltima versi�n...");
            BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
            String linea = br.readLine();
            escribir("Ok\n");
            if (linea != null) {
                escribir("Versi�n mas reciente: " + linea + "\n");
                if (Principal.version < Double.parseDouble(linea)) {
                    lblEstado.setText("Hay una nueva versi�n: Apeiron " + linea);
                    escribir("Puede obtener la actualizaci�n de: http://apeiron.sourceforge.net\n");
                    btnActualizar.setEnabled(true);
                    setVisible(true);
                } else {
                    lblEstado.setText("Usted tiene la �ltima versi�n");
                }
            }
            br.close();
        } catch (MalformedURLException e) {
            escribir("Fall�\n" + e + "\n");
            e.printStackTrace();
        } catch (IOException e) {
            escribir("Fall�\n" + e + "\n");
            e.printStackTrace();
        }
        btnReintentar.setEnabled(true);
    }
public static void insert(Connection c, MLPApprox net, int azioneId, String descrizione, int[] indiciID, int output, Date from, Date to) throws SQLException {
        try {
            PreparedStatement ps = c.prepareStatement(insertNet, PreparedStatement.RETURN_GENERATED_KEYS);
            ArrayList<Integer> indexes = new ArrayList<Integer>(indiciID.length);
            for (int i = 0; i < indiciID.length; i++) indexes.add(indiciID[i]);
            ps.setObject(1, net);
            ps.setInt(2, azioneId);
            ps.setObject(3, indexes);
            ps.setInt(4, output);
            ps.setDate(5, from);
            ps.setDate(6, to);
            ps.setString(7, descrizione);
            ps.executeUpdate();
            ResultSet key = ps.getGeneratedKeys();
            if (key.next()) {
                int id = key.getInt(1);
                for (int i = 0; i < indiciID.length; i++) {
                    PreparedStatement psIndex = c.prepareStatement(insertNetIndex);
                    psIndex.setInt(1, indiciID[i]);
                    psIndex.setInt(2, id);
                    psIndex.executeUpdate();
                }
            }
        } catch (SQLException e) {
            e.printStackTrace();
            try {
                c.rollback();
            } catch (SQLException e1) {
                e1.printStackTrace();
                throw e1;
            }
            throw e;
        }
    }
public void getDataFiles(String server, String username, String password, String folder, String destinationFolder) {
        try {
            FTPClient ftp = new FTPClient();
            ftp.connect(server);
            ftp.login(username, password);
            System.out.println("Connected to " + server + ".");
            System.out.print(ftp.getReplyString());
            ftp.enterLocalActiveMode();
            ftp.changeWorkingDirectory(folder);
            System.out.println("Changed to " + folder);
            FTPFile[] files = ftp.listFiles();
            System.out.println("Number of files in dir: " + files.length);
            for (int i = 0; i < files.length; i++) {
                getFiles(ftp, files[i], destinationFolder);
            }
            ftp.logout();
            ftp.disconnect();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
public void putDataFiles(String server, String username, String password, String folder, String destinationFolder) {
        try {
            FTPClient ftp = new FTPClient();
            ftp.connect(server);
            System.out.println("Connected");
            ftp.login(username, password);
            System.out.println("Logged in to " + server + ".");
            System.out.print(ftp.getReplyString());
            ftp.changeWorkingDirectory(destinationFolder);
            System.out.println("Changed to directory " + destinationFolder);
            File localRoot = new File(folder);
            File[] files = localRoot.listFiles();
            System.out.println("Number of files in dir: " + files.length);
            for (int i = 0; i < files.length; i++) {
                putFiles(ftp, files[i]);
            }
            ftp.logout();
            ftp.disconnect();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
private Document getResponse(HttpGet request) throws ClientProtocolException, IOException, ParserConfigurationException, IllegalStateException, SAXException, NoRoutesException {
        HttpClient httpClient = new DefaultHttpClient();
        HttpResponse response = httpClient.execute(request);
        if (response.getStatusLine().getStatusCode() != HTTP_STATUS_OK) throw new ClientProtocolException("The HTTP request is wrong.");
        allResponse = EntityUtils.toString(response.getEntity());
        String responseText = "";
        switch(modeOption) {
            case DRIVING:
                try {
                    responseText = allResponse.substring(allResponse.indexOf("<ol"), allResponse.indexOf("</ol>") + 5);
                } catch (Exception e) {
                    throw new NoRoutesException();
                }
                break;
            case WALKING:
                try {
                    responseText = allResponse.substring(allResponse.indexOf("<ol"), allResponse.indexOf("</ol>") + 5);
                } catch (Exception e) {
                    throw new NoRoutesException();
                }
                break;
            case PUBLIC_TRANSIT:
                String responseWithErrors = "";
                try {
                    responseWithErrors = allResponse.substring(allResponse.indexOf("<div id=\"tsp\">"), allResponse.indexOf("<div class=\"ddwpt\" id=\"panel_ddw1\" oi=\"wi1\">"));
                } catch (Exception e) {
                    throw new NoRoutesException();
                }
                responseText = responseWithErrors.replaceAll(".gif\">", ".gif\"/>").replaceAll("colspan=2", "colspan=\"2\"").replaceAll("nowrap", "").replaceAll("&laquo;", "").replaceAll("&nbsp;", "").replaceAll("&raquo;", "");
                break;
        }
        File xmlFile = new File("./data/temp/response.xml");
        PrintWriter writer = new PrintWriter(xmlFile);
        writer.println(responseText);
        writer.close();
        DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        return dBuilder.parse(xmlFile);
    }
@Override
    public boolean copy(Document document, Folder folder) throws Exception {
        boolean isCopied = false;
        if (document.getId() != null && folder.getId() != null) {
            Document copiedDoc = new DocumentModel();
            copiedDoc.setValues(document.getValues());
            copiedDoc.setFolder(folder);
            copiedDoc.setId(null);
            em.persist(copiedDoc);
            resourceAuthorityService.applyAuthority(copiedDoc);
            List<Preference> preferences = prefService.findAll();
            Preference preference = new PreferenceModel();
            if (preferences != null && !preferences.isEmpty()) {
                preference = preferences.get(0);
            }
            String repo = preference.getRepository();
            SimpleDateFormat sdf = new SimpleDateFormat(Constants.DATEFORMAT_YYYYMMDD);
            Calendar calendar = Calendar.getInstance();
            StringBuffer sbRepo = new StringBuffer(repo);
            sbRepo.append(File.separator);
            StringBuffer sbFolder = new StringBuffer(sdf.format(calendar.getTime()));
            sbFolder.append(File.separator).append(calendar.get(Calendar.HOUR_OF_DAY));
            File fFolder = new File(sbRepo.append(sbFolder).toString());
            if (!fFolder.exists()) {
                fFolder.mkdirs();
            }
            copiedDoc.setLocation(sbFolder.toString());
            em.merge(copiedDoc);
            File in = new File(repo + File.separator + document.getLocation() + File.separator + document.getId() + "." + document.getExt());
            File out = new File(fFolder.getAbsolutePath() + File.separator + copiedDoc.getId() + "." + copiedDoc.getExt());
            FileChannel inChannel = new FileInputStream(in).getChannel();
            FileChannel outChannel = new FileOutputStream(out).getChannel();
            try {
                inChannel.transferTo(0, inChannel.size(), outChannel);
            } catch (IOException e) {
                throw e;
            } finally {
                if (inChannel != null) inChannel.close();
                if (outChannel != null) outChannel.close();
            }
        }
        return isCopied;
    }
public void readData(int choice) throws IOException {
        for (i = 0; i < max; i++) for (j = 0; j < max; j++) {
            phase_x[i][j] = 0.0;
            phase_y[i][j] = 0.0;
        }
        URL url;
        InputStream is;
        InputStreamReader isr;
        if (choice == 0) {
            url = getClass().getResource("resources/Phase_623_620_Achromat.dat");
            is = url.openStream();
            isr = new InputStreamReader(is);
        } else {
            url = getClass().getResource("resources/Phase_623_620_NoAchromat.dat");
            is = url.openStream();
            isr = new InputStreamReader(is);
        }
        BufferedReader br = new BufferedReader(isr);
        s = br.readLine();
        StringTokenizer st = new StringTokenizer(s);
        i = 0;
        j = 0;
        phase_x[i][j] = 4 * Double.parseDouble(st.nextToken());
        phase_y[i][j] = 4 * Double.parseDouble(st.nextToken());
        xgridmin = phase_x[i][j];
        ygridmin = phase_y[i][j];
        temp_prev = phase_x[i][j];
        kd[i][j] = Double.parseDouble(st.nextToken());
        kfs[i][j] = Double.parseDouble(st.nextToken());
        kfl[i][j] = Double.parseDouble(st.nextToken());
        kdee[i][j] = Double.parseDouble(st.nextToken());
        kdc[i][j] = Double.parseDouble(st.nextToken());
        kfc[i][j] = Double.parseDouble(st.nextToken());
        j++;
        int k = 0;
        while ((s = br.readLine()) != null) {
            st = new StringTokenizer(s);
            temp_new = 4 * Double.parseDouble(st.nextToken());
            if (temp_new != temp_prev) {
                temp_prev = temp_new;
                i++;
                j = 0;
            }
            phase_x[i][j] = temp_new;
            phase_y[i][j] = 4 * Double.parseDouble(st.nextToken());
            kd[i][j] = Double.parseDouble(st.nextToken());
            kfs[i][j] = Double.parseDouble(st.nextToken());
            kfl[i][j] = Double.parseDouble(st.nextToken());
            kdee[i][j] = Double.parseDouble(st.nextToken());
            kdc[i][j] = Double.parseDouble(st.nextToken());
            kfc[i][j] = Double.parseDouble(st.nextToken());
            imax = i;
            jmax = j;
            j++;
            k++;
        }
        xgridmax = phase_x[i][j - 1];
        ygridmax = phase_y[i][j - 1];
    }
public static JuneClass loadClass(Map<String, Entity> globals, String packageName, String baseClassName) {
        try {
            JuneClass $class = null;
            String resourceName = (packageName.length() > 0 ? packageName.replace('.', '/') + "/" : "") + baseClassName.replace('.', '$') + ".class";
            URL url = Resolver.class.getClassLoader().getResource(resourceName);
            if (url != null) {
                ClassBuilder builder = new ClassBuilder(globals);
                InputStream stream = url.openStream();
                try {
                    new ClassReader(new BufferedInputStream(stream)).accept(builder, ClassReader.SKIP_CODE);
                } finally {
                    stream.close();
                }
                $class = builder.$class;
                $class.loaded = true;
            }
            return $class;
        } catch (Exception e) {
            throw Helper.throwAny(e);
        }
    }
public static void copyFileNIO(String src, String dst) {
        try {
            FileChannel srcChannel = new FileInputStream(src).getChannel();
            FileChannel dstChannel = new FileOutputStream(dst).getChannel();
            dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
            srcChannel.close();
            dstChannel.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
@Test
    public void config() throws IOException {
        Reader reader = new FileReader(new File("src/test/resources/test.yml"));
        Writer writer = new FileWriter(new File("src/site/apt/config.apt"));
        writer.write("------\n");
        writer.write(FileUtils.readFully(reader));
        writer.flush();
        writer.close();
    }
public static String scramble(String text) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-1");
            md.update(text.getBytes("UTF-8"));
            StringBuffer sb = new StringBuffer();
            for (byte b : md.digest()) sb.append(Integer.toString(b & 0xFF, 16));
            return sb.toString();
        } catch (UnsupportedEncodingException e) {
            return null;
        } catch (NoSuchAlgorithmException e) {
            return null;
        }
    }