semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public void readData() throws IOException {
        i = 0;
        j = 0;
        URL url = getClass().getResource("resources/tuneGridMaster.dat");
        InputStream is = url.openStream();
        InputStreamReader isr = new InputStreamReader(is);
        BufferedReader br = new BufferedReader(isr);
        s = br.readLine();
        StringTokenizer st = new StringTokenizer(s);
        tune_x[i][j] = Double.parseDouble(st.nextToken());
        gridmin = tune_x[i][j];
        temp_prev = tune_x[i][j];
        tune_y[i][j] = 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());
        j++;
        int k = 0;
        while ((s = br.readLine()) != null) {
            st = new StringTokenizer(s);
            temp_new = Double.parseDouble(st.nextToken());
            if (temp_new != temp_prev) {
                temp_prev = temp_new;
                i++;
                j = 0;
            }
            tune_x[i][j] = temp_new;
            tune_y[i][j] = 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++;
        }
        gridmax = tune_x[i][j - 1];
    }
private void createSaveServiceProps() throws MojoExecutionException {
        saveServiceProps = new File(workDir, "saveservice.properties");
        try {
            FileWriter out = new FileWriter(saveServiceProps);
            IOUtils.copy(Thread.currentThread().getContextClassLoader().getResourceAsStream("saveservice.properties"), out);
            out.flush();
            out.close();
            System.setProperty("saveservice_properties", File.separator + "target" + File.separator + "jmeter" + File.separator + "saveservice.properties");
        } catch (IOException e) {
            throw new MojoExecutionException("Could not create temporary saveservice.properties", e);
        }
    }
public void registerSchema(String newSchemaName, String objectControlller, long boui, String expression, String schema) throws SQLException {
        Connection cndef = null;
        PreparedStatement pstm = null;
        try {
            cndef = this.getRepositoryConnection(p_ctx.getApplication(), "default", 2);
            String friendlyName = MessageLocalizer.getMessage("SCHEMA_CREATED_BY_OBJECT") + " [" + objectControlller + "] " + MessageLocalizer.getMessage("WITH_BOUI") + " [" + boui + "]";
            pstm = cndef.prepareStatement("DELETE FROM NGTDIC WHERE TABLENAME=? and objecttype='S'");
            pstm.setString(1, newSchemaName);
            pstm.executeUpdate();
            pstm.close();
            pstm = cndef.prepareStatement("INSERT INTO NGTDIC (SCHEMA,OBJECTNAME,OBJECTTYPE,TABLENAME, " + "FRIENDLYNAME, EXPRESSION) VALUES (" + "?,?,?,?,?,?)");
            pstm.setString(1, schema);
            pstm.setString(2, newSchemaName);
            pstm.setString(3, "S");
            pstm.setString(4, newSchemaName);
            pstm.setString(5, friendlyName);
            pstm.setString(6, expression);
            pstm.executeUpdate();
            pstm.close();
            cndef.commit();
        } catch (Exception e) {
            cndef.rollback();
            e.printStackTrace();
            throw new SQLException(e.getMessage());
        } finally {
            if (pstm != null) {
                try {
                    pstm.close();
                } catch (Exception e) {
                }
            }
        }
    }
public static final boolean zipExtract(String zipfile, String name, String dest) {
        boolean f = false;
        try {
            InputStream in = new BufferedInputStream(new FileInputStream(zipfile));
            ZipInputStream zin = new ZipInputStream(in);
            ZipEntry e;
            while ((e = zin.getNextEntry()) != null) {
                if (e.getName().equals(name)) {
                    FileOutputStream out = new FileOutputStream(dest);
                    byte b[] = new byte[TEMP_FILE_BUFFER_SIZE];
                    int len = 0;
                    while ((len = zin.read(b)) != -1) out.write(b, 0, len);
                    out.close();
                    f = true;
                    break;
                }
            }
            zin.close();
        } catch (FileNotFoundException e) {
            MLUtil.runtimeError(e, "extractZip " + zipfile + " " + name);
        } catch (IOException e) {
            MLUtil.runtimeError(e, "extractZip " + zipfile + " " + name);
        }
        return (f);
    }
public static final boolean zipUpdate(String zipfile, String name, String oldname, byte[] contents, boolean delete) {
        try {
            File temp = File.createTempFile("atf", ".zip");
            InputStream in = new BufferedInputStream(new FileInputStream(zipfile));
            OutputStream os = new BufferedOutputStream(new FileOutputStream(temp));
            ZipInputStream zin = new ZipInputStream(in);
            ZipOutputStream zout = new ZipOutputStream(os);
            ZipEntry e;
            ZipEntry e2;
            byte buffer[] = new byte[TEMP_FILE_BUFFER_SIZE];
            int bytesRead;
            boolean found = false;
            boolean rename = false;
            String oname = name;
            if (oldname != null) {
                name = oldname;
                rename = true;
            }
            while ((e = zin.getNextEntry()) != null) {
                if (!e.isDirectory()) {
                    String ename = e.getName();
                    if (delete && ename.equals(name)) continue;
                    e2 = new ZipEntry(rename ? oname : ename);
                    zout.putNextEntry(e2);
                    if (ename.equals(name)) {
                        found = true;
                        zout.write(contents);
                    } else {
                        while ((bytesRead = zin.read(buffer)) != -1) zout.write(buffer, 0, bytesRead);
                    }
                    zout.closeEntry();
                }
            }
            if (!found && !delete) {
                e = new ZipEntry(name);
                zout.putNextEntry(e);
                zout.write(contents);
                zout.closeEntry();
            }
            zin.close();
            zout.close();
            File fp = new File(zipfile);
            fp.delete();
            MLUtil.copyFile(temp, fp);
            temp.delete();
            return (true);
        } catch (FileNotFoundException e) {
            MLUtil.runtimeError(e, "updateZip " + zipfile + " " + name);
        } catch (IOException e) {
            MLUtil.runtimeError(e, "updateZip " + zipfile + " " + name);
        }
        return (false);
    }
@Override
    public void download(String remoteFilePath, String localFilePath) {
        InputStream remoteStream = null;
        try {
            remoteStream = client.get(remoteFilePath);
        } catch (IOException e) {
            e.printStackTrace();
        }
        OutputStream localStream = null;
        try {
            localStream = new FileOutputStream(new File(localFilePath));
        } catch (FileNotFoundException e1) {
            e1.printStackTrace();
        }
        try {
            IOUtils.copy(remoteStream, localStream);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
public T08OTSDTMInterpositionUnitTestCase(String name) throws java.io.IOException {
        super(name);
        java.net.URL url = ClassLoader.getSystemResource("host0.cosnaming.jndi.properties");
        jndiProps = new java.util.Properties();
        jndiProps.load(url.openStream());
    }
public static void copyFile(File in, File out) throws IOException {
        FileChannel sourceChannel = new FileInputStream(in).getChannel();
        FileChannel destinationChannel = new FileOutputStream(out).getChannel();
        sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
        sourceChannel.close();
        destinationChannel.close();
    }
@Override
    public void run() {
        try {
            long pos = begin;
            byte[] buf = new byte[1024];
            URLConnection cn = url.openConnection();
            Utils.setHeader(cn);
            cn.setRequestProperty("Range", "bytes=" + begin + "-" + end);
            BufferedInputStream bis = new BufferedInputStream(cn.getInputStream());
            int len;
            while ((len = bis.read(buf)) > 0) {
                synchronized (file) {
                    file.seek(pos);
                    file.write(buf, 0, len);
                }
                pos += len;
                Statics.getInstance().addComleted(len);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        latch.countDown();
    }
protected String contentString() {
        String result = null;
        URL url;
        String encoding = null;
        try {
            url = url();
            URLConnection connection = url.openConnection();
            connection.setDoInput(true);
            connection.setDoOutput(false);
            connection.setUseCaches(false);
            for (Enumeration e = bindingKeys().objectEnumerator(); e.hasMoreElements(); ) {
                String key = (String) e.nextElement();
                if (key.startsWith("?")) {
                    connection.setRequestProperty(key.substring(1), valueForBinding(key).toString());
                }
            }
            if (connection.getContentEncoding() != null) {
                encoding = connection.getContentEncoding();
            }
            if (encoding == null) {
                encoding = (String) valueForBinding("encoding");
            }
            if (encoding == null) {
                encoding = "UTF-8";
            }
            InputStream stream = connection.getInputStream();
            byte bytes[] = ERXFileUtilities.bytesFromInputStream(stream);
            stream.close();
            result = new String(bytes, encoding);
        } catch (IOException ex) {
            throw NSForwardException._runtimeExceptionForThrowable(ex);
        }
        return result;
    }
protected static byte[] hashPassword(byte[] saltBytes, String plaintextPassword) throws AssertionError {
        MessageDigest digest;
        try {
            digest = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException ex) {
            throw (AssertionError) new AssertionError("No MD5 message digest supported.").initCause(ex);
        }
        digest.update(saltBytes);
        try {
            digest.update(plaintextPassword.getBytes("utf-8"));
        } catch (UnsupportedEncodingException ex) {
            throw (AssertionError) new AssertionError("No UTF-8 encoding supported.").initCause(ex);
        }
        byte[] passwordBytes = digest.digest();
        return passwordBytes;
    }
public static String getMD5Str(String str) {
        MessageDigest messageDigest = null;
        try {
            messageDigest = MessageDigest.getInstance("MD5");
            messageDigest.reset();
            messageDigest.update(str.getBytes("UTF-8"));
        } catch (NoSuchAlgorithmException e) {
            System.out.println("NoSuchAlgorithmException caught!");
            System.exit(-1);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        byte[] byteArray = messageDigest.digest();
        StringBuffer md5StrBuff = new StringBuffer();
        for (int i = 0; i < byteArray.length; i++) {
            if (Integer.toHexString(0xFF & byteArray[i]).length() == 1) md5StrBuff.append("0").append(Integer.toHexString(0xFF & byteArray[i])); else md5StrBuff.append(Integer.toHexString(0xFF & byteArray[i]));
        }
        return md5StrBuff.toString();
    }
public int readRaw(byte[] buffer, int offset, int length) throws IOException {
        if (offset < 0 || length < 0 || (offset + length) > buffer.length) {
            throw new IndexOutOfBoundsException();
        }
        HttpURLConnection connection = null;
        InputStream is = null;
        int n = 0;
        try {
            connection = (HttpURLConnection) url.openConnection();
            String byteRange = "bytes=" + position + "-" + (position + length - 1);
            connection.setRequestProperty("Range", byteRange);
            is = connection.getInputStream();
            while (n < length) {
                int count = is.read(buffer, offset + n, length - n);
                if (count < 0) {
                    throw new EOFException();
                }
                n += count;
            }
            position += n;
            return n;
        } catch (EOFException e) {
            return n;
        } catch (IOException e) {
            e.printStackTrace();
            System.out.println("We're screwed...");
            System.out.println(n);
            if (e.getMessage().contains("response code: 416")) {
                System.out.println("Trying to be mister nice guy, returning " + n);
                return n;
            } else {
                throw e;
            }
        } finally {
            if (is != null) {
                is.close();
            }
            if (connection != null) {
                connection.disconnect();
            }
        }
    }
public static void upload(FTPDetails ftpDetails) {
        FTPClient ftp = new FTPClient();
        try {
            String host = ftpDetails.getHost();
            logger.info("Connecting to ftp host: " + host);
            ftp.connect(host);
            logger.info("Received reply from ftp :" + ftp.getReplyString());
            ftp.login(ftpDetails.getUserName(), ftpDetails.getPassword());
            ftp.setFileType(FTP.BINARY_FILE_TYPE);
            ftp.makeDirectory(ftpDetails.getRemoterDirectory());
            logger.info("Created directory :" + ftpDetails.getRemoterDirectory());
            ftp.changeWorkingDirectory(ftpDetails.getRemoterDirectory());
            BufferedInputStream ftpInput = new BufferedInputStream(new FileInputStream(new File(ftpDetails.getLocalFilePath())));
            OutputStream storeFileStream = ftp.storeFileStream(ftpDetails.getRemoteFileName());
            IOUtils.copy(ftpInput, storeFileStream);
            logger.info("Copied file : " + ftpDetails.getLocalFilePath() + " >>> " + host + ":/" + ftpDetails.getRemoterDirectory() + "/" + ftpDetails.getRemoteFileName());
            ftpInput.close();
            storeFileStream.close();
            ftp.logout();
            ftp.disconnect();
            logger.info("Logged out. ");
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
public static void copyFile(File in, File out) throws IOException {
        FileChannel sourceChannel = new FileInputStream(in).getChannel();
        try {
            FileChannel destinationChannel = new FileOutputStream(out).getChannel();
            try {
                sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
            } finally {
                destinationChannel.close();
            }
        } finally {
            sourceChannel.close();
        }
    }
public void add(String language, String tag, String root, String surface) throws FidoDatabaseException, MorphologyTagNotFoundException {
        try {
            Connection conn = null;
            Statement stmt = null;
            try {
                conn = FidoDataSource.getConnection();
                conn.setAutoCommit(false);
                stmt = conn.createStatement();
                if (containsTag(stmt, tag) == false) throw new MorphologyTagNotFoundException(tag);
                if (isRuleUnique(stmt, language, tag, root, surface) == false) return;
                int row;
                if (root.equals("*") == true) row = getAppendRowForTag(stmt, language, tag); else if (root.indexOf('*') == -1) row = getFirstRowForTag(stmt, language, tag); else row = getFirstRegularFormForTag(stmt, language, tag);
                boolean use = determineRecognitionUse(root, surface);
                bumpAllRowsDown(stmt, language, tag, row);
                String sql = "insert into LanguageMorphologies (LanguageName, Rank, Root, Surface, MorphologyTag, Used) " + "values ('" + language + "', " + row + ", '" + root + "', '" + surface + "', '" + tag + "', ";
                if (use == true) sql = sql + "TRUE)"; else sql = sql + "FALSE)";
                stmt.executeUpdate(sql);
                conn.commit();
            } catch (SQLException e) {
                if (conn != null) conn.rollback();
                throw e;
            } finally {
                if (stmt != null) stmt.close();
                if (conn != null) conn.close();
            }
        } catch (SQLException e) {
            throw new FidoDatabaseException(e);
        }
    }
public void delete(String language, String tag, int row) throws FidoDatabaseException {
        try {
            Connection conn = null;
            Statement stmt = null;
            try {
                String sql = "delete from LanguageMorphologies " + "where LanguageName = '" + language + "' and MorphologyTag = '" + tag + "' and " + "      Rank = " + row;
                conn = fido.util.FidoDataSource.getConnection();
                conn.setAutoCommit(false);
                stmt = conn.createStatement();
                stmt.executeUpdate(sql);
                bumpAllRowsUp(stmt, language, tag, row);
                conn.commit();
            } catch (SQLException e) {
                if (conn != null) conn.rollback();
                throw e;
            } finally {
                if (stmt != null) stmt.close();
                if (conn != null) conn.close();
            }
        } catch (SQLException e) {
            throw new FidoDatabaseException(e);
        }
    }
public void moveRuleUp(String language, String tag, int row) throws FidoDatabaseException {
        try {
            Connection conn = null;
            Statement stmt = null;
            try {
                conn = fido.util.FidoDataSource.getConnection();
                conn.setAutoCommit(false);
                stmt = conn.createStatement();
                int max = findMaxRank(stmt, language, tag);
                if ((row < 2) || (row > max)) throw new IllegalArgumentException("Row number (" + row + ") was not between 2 and " + max);
                stmt.executeUpdate("update LanguageMorphologies set Rank = -1 " + "where Rank = " + row + " and MorphologyTag = '" + tag + "' and " + "      LanguageName = '" + language + "'");
                stmt.executeUpdate("update LanguageMorphologies set Rank = " + row + "where Rank = " + (row - 1) + " and MorphologyTag = '" + tag + "' and " + "      LanguageName = '" + language + "'");
                stmt.executeUpdate("update LanguageMorphologies set Rank = " + (row - 1) + "where Rank = -1 and MorphologyTag = '" + tag + "' and " + "      LanguageName = '" + language + "'");
                conn.commit();
            } catch (SQLException e) {
                if (conn != null) conn.rollback();
                throw e;
            } finally {
                if (stmt != null) stmt.close();
                if (conn != null) conn.close();
            }
        } catch (SQLException e) {
            throw new FidoDatabaseException(e);
        }
    }
public void moveRuleDown(String language, String tag, int row) throws FidoDatabaseException {
        try {
            Connection conn = null;
            Statement stmt = null;
            try {
                conn = fido.util.FidoDataSource.getConnection();
                conn.setAutoCommit(false);
                stmt = conn.createStatement();
                int max = findMaxRank(stmt, language, tag);
                if ((row < 1) || (row > (max - 1))) throw new IllegalArgumentException("Row number (" + row + ") was not between 1 and " + (max - 1));
                stmt.executeUpdate("update LanguageMorphologies set Rank = -1 " + "where Rank = " + row + " and MorphologyTag = '" + tag + "' and " + "      LanguageName = '" + language + "'");
                stmt.executeUpdate("update LanguageMorphologies set Rank = " + row + "where Rank = " + (row + 1) + " and MorphologyTag = '" + tag + "' and " + "      LanguageName = '" + language + "'");
                stmt.executeUpdate("update LanguageMorphologies set Rank = " + (row + 1) + "where Rank = -1 and MorphologyTag = '" + tag + "' and " + "      LanguageName = '" + language + "'");
                conn.commit();
            } catch (SQLException e) {
                if (conn != null) conn.rollback();
                throw e;
            } finally {
                if (stmt != null) stmt.close();
                if (conn != null) conn.close();
            }
        } catch (SQLException e) {
            throw new FidoDatabaseException(e);
        }
    }
private void checkSites() {
            Log.d(LOG_TAG, "Updating sites: " + sitesToCheck.keySet().toString());
            for (Map.Entry<Site, Item> entry : sitesToCheck.entrySet()) {
                final Site site = entry.getKey();
                final Item oldItem = entry.getValue();
                try {
                    final HttpGet req = new HttpGet(site.getUrl().toURI());
                    req.addHeader("Cache-Control", "no-cache");
                    req.addHeader("Pragma", "no-cache");
                    if (oldItem != null) {
                        final Date lastModified = oldItem.getTimestamp();
                        if (lastModified != null) {
                            req.addHeader("If-Modified-Since", Utils.formatRFC822Date(lastModified));
                        }
                    }
                    final HttpResponse response = httpClient.execute(req);
                    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                        final FeedHandler handler = site.getHandler().newInstance();
                        final InputStream in = response.getEntity().getContent();
                        Xml.parse(in, site.getEncoding(), handler);
                        in.close();
                        notify(site, handler.getCurrentItem());
                    } else if (response.getStatusLine().getStatusCode() != 304) {
                        Log.e(LOG_TAG, "HTTP request for " + site.name() + " failed: " + response.getStatusLine().toString());
                    }
                } catch (Throwable e) {
                    Log.e(LOG_TAG, e.getMessage(), e);
                }
            }
        }