semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
private File sendQuery(String query) throws MusicBrainzException {
        File xmlServerResponse = null;
        try {
            xmlServerResponse = new File(SERVER_RESPONSE_FILE);
            long start = Calendar.getInstance().getTimeInMillis();
            System.out.println("\n\n++++++++++++++++++++++++++++++++++++++++++++++++++++");
            System.out.println("    consulta de busqueda -> " + query);
            URL url = new URL(query);
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            String response = "";
            String line = "";
            System.out.println("    Respuesta del servidor: \n");
            while ((line = in.readLine()) != null) {
                response += line;
            }
            xmlServerResponse = new File(SERVER_RESPONSE_FILE);
            System.out.println("    Ruta del archivo XML -> " + xmlServerResponse.getAbsolutePath());
            BufferedWriter out = new BufferedWriter(new FileWriter(xmlServerResponse));
            out.write(response);
            out.close();
            System.out.println("Tamanho del xmlFile -> " + xmlServerResponse.length());
            long ahora = (Calendar.getInstance().getTimeInMillis() - start);
            System.out.println(" Tiempo transcurrido en la consulta (en milesimas) -> " + ahora);
            System.out.println("++++++++++++++++++++++++++++++++++++++++++++++++++++\n\n");
        } catch (IOException e) {
            e.printStackTrace();
            String msg = e.getMessage();
            if (e instanceof FileNotFoundException) {
                msg = "ERROR: MusicBrainz URL used is not found:\n" + msg;
            } else {
            }
            throw new MusicBrainzException(msg);
        }
        return xmlServerResponse;
    }
protected N save(String sql, Object[] args) {
        Connection conn = null;
        PreparedStatement pstmt = null;
        ResultSet rs = null;
        try {
            conn = JdbcUtils.getConnection();
            conn.setAutoCommit(false);
            pstmt = conn.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
            this.setParameters(pstmt, args);
            pstmt.executeUpdate();
            conn.commit();
            conn.setAutoCommit(true);
            rs = pstmt.getGeneratedKeys();
            return (N) rs.getObject(1);
        } catch (SQLException e) {
            try {
                if (conn != null) {
                    conn.rollback();
                    conn.setAutoCommit(true);
                }
            } catch (SQLException ex) {
                ex.printStackTrace();
            }
            throw new JdbcDaoException(e.getMessage(), e);
        } finally {
            JdbcUtils.free(rs, pstmt, conn);
        }
    }
protected void update(String sql, Object[] args) {
        Connection conn = null;
        PreparedStatement pstmt = null;
        try {
            conn = JdbcUtils.getConnection();
            conn.setAutoCommit(false);
            pstmt = conn.prepareStatement(sql);
            this.setParameters(pstmt, args);
            pstmt.executeUpdate();
            conn.commit();
            conn.setAutoCommit(true);
        } catch (SQLException e) {
            try {
                if (conn != null) {
                    conn.rollback();
                    conn.setAutoCommit(true);
                }
            } catch (SQLException ex) {
                ex.printStackTrace();
            }
            throw new JdbcDaoException(e.getMessage(), e);
        } finally {
            JdbcUtils.free(pstmt, conn);
        }
    }
public static void main(String[] s) throws Exception {
        System.setProperty("http.proxyHost", "ser");
        System.setProperty("http.proxyPort", "3128");
        URL url = new URL("http", "me", 80, "/");
        HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();
        Authenticator.setDefault(new TestAuthenticator());
        System.out.println("usingproxy status - " + urlConn.usingProxy());
        System.out.println("Class name - " + urlConn.getClass().getName());
        InputStream in = url.openStream();
        BufferedReader theReader = new BufferedReader(new InputStreamReader(url.openStream()));
        final int kMaxSizeHTML = 100000;
        char readBuffer[] = new char[kMaxSizeHTML];
        int countRead = theReader.read(readBuffer, 0, kMaxSizeHTML);
        String contentStr = "";
        String tmpStr;
        BufferedWriter wr = new BufferedWriter(new FileWriter("c:\\opt1\\auth-proxy.txt"));
        while ((countRead != -1) && (countRead != 0) && (contentStr.length() < kMaxSizeHTML)) {
            wr.write(readBuffer, 0, countRead);
            tmpStr = new String(readBuffer, 0, countRead);
            contentStr += tmpStr;
            countRead = theReader.read(readBuffer, 0, kMaxSizeHTML);
        }
        wr.flush();
        wr.close();
        wr = null;
    }
private boolean initConnection() {
        try {
            if (ftp == null) {
                ftp = new FTPClient();
                serverIP = getServer();
                userName = getUserName();
                password = getPassword();
            }
            ftp.connect(serverIP);
            ftp.login(userName, password);
            return true;
        } catch (SocketException a_excp) {
            throw new RuntimeException(a_excp);
        } catch (IOException a_excp) {
            throw new RuntimeException(a_excp);
        } catch (Throwable a_th) {
            throw new RuntimeException(a_th);
        }
    }
private boolean copyFiles(File sourceDir, File destinationDir) {
        boolean result = false;
        try {
            if (sourceDir != null && destinationDir != null && sourceDir.exists() && destinationDir.exists() && sourceDir.isDirectory() && destinationDir.isDirectory()) {
                File sourceFiles[] = sourceDir.listFiles();
                if (sourceFiles != null && sourceFiles.length > 0) {
                    File destFiles[] = destinationDir.listFiles();
                    if (destFiles != null && destFiles.length > 0) {
                        for (int i = 0; i < destFiles.length; i++) {
                            if (destFiles[i] != null) {
                                destFiles[i].delete();
                            }
                        }
                    }
                    for (int i = 0; i < sourceFiles.length; i++) {
                        if (sourceFiles[i] != null && sourceFiles[i].exists() && sourceFiles[i].isFile()) {
                            String fileName = destFiles[i].getName();
                            File destFile = new File(destinationDir.getAbsolutePath() + "/" + fileName);
                            if (!destFile.exists()) destFile.createNewFile();
                            FileInputStream in = new FileInputStream(sourceFiles[i]);
                            FileOutputStream out = new FileOutputStream(destFile);
                            FileChannel fcIn = in.getChannel();
                            FileChannel fcOut = out.getChannel();
                            fcIn.transferTo(0, fcIn.size(), fcOut);
                        }
                    }
                }
            }
            result = true;
        } catch (Exception e) {
            System.out.println("Exception in copyFiles Method : " + e);
        }
        return result;
    }
@Deprecated
    public boolean backupLuceneIndex(int indexLocation, int backupLocation) {
        boolean result = false;
        try {
            System.out.println("lucene backup started");
            String indexPath = this.getIndexFolderPath(indexLocation);
            String backupPath = this.getIndexFolderPath(backupLocation);
            File inDir = new File(indexPath);
            boolean flag = true;
            if (inDir.exists() && inDir.isDirectory()) {
                File filesList[] = inDir.listFiles();
                if (filesList != null) {
                    File parDirBackup = new File(backupPath);
                    if (!parDirBackup.exists()) parDirBackup.mkdir();
                    String date = this.getDate();
                    backupPath += "/" + date;
                    File dirBackup = new File(backupPath);
                    if (!dirBackup.exists()) dirBackup.mkdir(); else {
                        File files[] = dirBackup.listFiles();
                        if (files != null) {
                            for (int i = 0; i < files.length; i++) {
                                if (files[i] != null) {
                                    files[i].delete();
                                }
                            }
                        }
                        dirBackup.delete();
                        dirBackup.mkdir();
                    }
                    for (int i = 0; i < filesList.length; i++) {
                        if (filesList[i].isFile()) {
                            try {
                                File destFile = new File(backupPath + "/" + filesList[i].getName());
                                if (!destFile.exists()) destFile.createNewFile();
                                FileInputStream in = new FileInputStream(filesList[i]);
                                FileOutputStream out = new FileOutputStream(destFile);
                                FileChannel fcIn = in.getChannel();
                                FileChannel fcOut = out.getChannel();
                                fcIn.transferTo(0, fcIn.size(), fcOut);
                            } catch (FileNotFoundException ex) {
                                System.out.println("FileNotFoundException ---->" + ex);
                                flag = false;
                            } catch (IOException excIO) {
                                System.out.println("IOException ---->" + excIO);
                                flag = false;
                            }
                        }
                    }
                }
            }
            System.out.println("lucene backup finished");
            System.out.println("flag ========= " + flag);
            if (flag) {
                result = true;
            }
        } catch (Exception e) {
            System.out.println("Exception in backupLuceneIndex Method : " + e);
            e.printStackTrace();
        }
        return result;
    }
public static int deleteOrder(String likePatten) {
        Connection conn = null;
        PreparedStatement psmt = null;
        StringBuffer SQL = new StringBuffer(200);
        int deleted = 0;
        SQL.append(" DELETE FROM JHF_ALIVE_ORDER ").append(" WHERE   ORDER_ID LIKE  ? ");
        try {
            conn = JdbcConnectionPool.mainConnection();
            conn.setAutoCommit(false);
            conn.setReadOnly(false);
            psmt = conn.prepareStatement(SQL.toString());
            psmt.setString(1, "%" + likePatten + "%");
            deleted = psmt.executeUpdate();
            conn.commit();
        } catch (SQLException e) {
            if (null != conn) {
                try {
                    conn.rollback();
                } catch (SQLException e1) {
                    System.out.println(" error when roll back !");
                }
            }
        } finally {
            try {
                if (null != psmt) {
                    psmt.close();
                    psmt = null;
                }
                if (null != conn) {
                    conn.close();
                    conn = null;
                }
            } catch (SQLException e) {
                System.out.println(" error  when psmt close or conn close .");
            }
        }
        return deleted;
    }
public static int deleteExecution(String likePatten) {
        Connection conn = null;
        PreparedStatement psmt = null;
        StringBuffer SQL = new StringBuffer(200);
        int deleted = 0;
        SQL.append(" DELETE FROM JHF_EXCEPTION ").append(" WHERE   ORDER_ID LIKE  ? ");
        try {
            conn = JdbcConnectionPool.mainConnection();
            conn.setAutoCommit(false);
            conn.setReadOnly(false);
            psmt = conn.prepareStatement(SQL.toString());
            psmt.setString(1, "%" + likePatten + "%");
            deleted = psmt.executeUpdate();
            conn.commit();
        } catch (SQLException e) {
            if (null != conn) {
                try {
                    conn.rollback();
                } catch (SQLException e1) {
                    System.out.println(" error when roll back !");
                }
            }
        } finally {
            try {
                if (null != psmt) {
                    psmt.close();
                    psmt = null;
                }
                if (null != conn) {
                    conn.close();
                    conn = null;
                }
            } catch (SQLException e) {
                System.out.println(" error  when psmt close or conn close .");
            }
        }
        return deleted;
    }
public static int deleteContract(String likePatten) {
        Connection conn = null;
        PreparedStatement psmt = null;
        StringBuffer SQL = new StringBuffer(200);
        int deleted = 0;
        SQL.append(" DELETE FROM JHF_ALIVE_CONTRACT ").append(" WHERE   ORDER_ID LIKE  ? ");
        try {
            conn = JdbcConnectionPool.mainConnection();
            conn.setAutoCommit(false);
            conn.setReadOnly(false);
            psmt = conn.prepareStatement(SQL.toString());
            psmt.setString(1, "%" + likePatten + "%");
            deleted = psmt.executeUpdate();
            conn.commit();
        } catch (SQLException e) {
            if (null != conn) {
                try {
                    conn.rollback();
                } catch (SQLException e1) {
                    System.out.println(" error when roll back !");
                }
            }
        } finally {
            try {
                if (null != psmt) {
                    psmt.close();
                    psmt = null;
                }
                if (null != conn) {
                    conn.close();
                    conn = null;
                }
            } catch (SQLException e) {
                System.out.println(" error  when psmt close or conn close .");
            }
        }
        return deleted;
    }
public static int deleteSysPosInsert() {
        Connection conn = null;
        PreparedStatement psmt = null;
        StringBuffer SQL = new StringBuffer(200);
        int deleted = 0;
        SQL.append(" DELETE FROM JHF_SYS_POSITION_INSERT ");
        try {
            conn = JdbcConnectionPool.mainConnection();
            conn.setAutoCommit(false);
            conn.setReadOnly(false);
            psmt = conn.prepareStatement(SQL.toString());
            deleted = psmt.executeUpdate();
            conn.commit();
        } catch (SQLException e) {
            if (null != conn) {
                try {
                    conn.rollback();
                } catch (SQLException e1) {
                    System.out.println(" error when roll back !");
                }
            }
        } finally {
            try {
                if (null != psmt) {
                    psmt.close();
                    psmt = null;
                }
                if (null != conn) {
                    conn.close();
                    conn = null;
                }
            } catch (SQLException e) {
                System.out.println(" error  when psmt close or conn close .");
            }
        }
        return deleted;
    }
public static int deleteOrderStatusHis(String likePatten) {
        Connection conn = null;
        PreparedStatement psmt = null;
        StringBuffer SQL = new StringBuffer(200);
        int deleted = 0;
        SQL.append(" DELETE FROM JHF_ORDER_STATUS_HISTORY ").append(" WHERE   ORDER_ID LIKE  ? ");
        try {
            conn = JdbcConnectionPool.mainConnection();
            conn.setAutoCommit(false);
            conn.setReadOnly(false);
            psmt = conn.prepareStatement(SQL.toString());
            psmt.setString(1, "%" + likePatten + "%");
            deleted = psmt.executeUpdate();
            conn.commit();
        } catch (SQLException e) {
            if (null != conn) {
                try {
                    conn.rollback();
                } catch (SQLException e1) {
                    System.out.println(" error when roll back !");
                }
            }
        } finally {
            try {
                if (null != psmt) {
                    psmt.close();
                    psmt = null;
                }
                if (null != conn) {
                    conn.close();
                    conn = null;
                }
            } catch (SQLException e) {
                System.out.println(" error  when psmt close or conn close .");
            }
        }
        return deleted;
    }
public static int deleteHedgeCustTrade() {
        Connection conn = null;
        PreparedStatement psmt = null;
        StringBuffer SQL = new StringBuffer(200);
        int deleted = 0;
        SQL.append(" DELETE FROM JHF_HEDGE_CUSTTRADE ");
        try {
            conn = JdbcConnectionPool.mainConnection();
            conn.setAutoCommit(false);
            conn.setReadOnly(false);
            psmt = conn.prepareStatement(SQL.toString());
            deleted = psmt.executeUpdate();
            conn.commit();
        } catch (SQLException e) {
            if (null != conn) {
                try {
                    conn.rollback();
                } catch (SQLException e1) {
                    System.out.println(" error when roll back !");
                }
            }
        } finally {
            try {
                if (null != psmt) {
                    psmt.close();
                    psmt = null;
                }
                if (null != conn) {
                    conn.close();
                    conn = null;
                }
            } catch (SQLException e) {
                System.out.println(" error  when psmt close or conn close .");
            }
        }
        return deleted;
    }
public static void main(String[] args) {
        FileInputStream in;
        DeflaterOutputStream out;
        FileOutputStream fos;
        FileDialog fd;
        fd = new FileDialog(new Frame(), "Find a file to deflate", FileDialog.LOAD);
        fd.show();
        if (fd.getFile() != null) {
            try {
                in = new FileInputStream(new File(fd.getDirectory(), fd.getFile()));
                fos = new FileOutputStream(new File("Deflated.out"));
                out = new DeflaterOutputStream(fos, new Deflater(Deflater.DEFLATED, true));
                int bytes_read = 0;
                byte[] buffer = new byte[1024];
                while ((bytes_read = in.read(buffer)) != -1) {
                    out.write(buffer, 0, bytes_read);
                }
                fos.flush();
                fos.close();
                out.flush();
                out.close();
                in.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println("Done");
        }
    }
public BufferedImage processUsingTemp(InputStream input, DjatokaDecodeParam params) throws DjatokaException {
        File in;
        try {
            in = File.createTempFile("tmp", ".jp2");
            FileOutputStream fos = new FileOutputStream(in);
            in.deleteOnExit();
            IOUtils.copyStream(input, fos);
        } catch (IOException e) {
            logger.error(e, e);
            throw new DjatokaException(e);
        }
        BufferedImage bi = process(in.getAbsolutePath(), params);
        if (in != null) in.delete();
        return bi;
    }
public BufferedImage process(final InputStream is, DjatokaDecodeParam params) throws DjatokaException {
        if (isWindows) return processUsingTemp(is, params);
        ArrayList<Double> dims = null;
        if (params.getRegion() != null) {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            IOUtils.copyStream(is, baos);
            dims = getRegionMetadata(new ByteArrayInputStream(baos.toByteArray()), params);
            return process(new ByteArrayInputStream(baos.toByteArray()), dims, params);
        } else return process(is, dims, params);
    }
public Document getContentAsDocument() {
        synchronized (this.url) {
            URLConnection connection = this.url.openConnection();
            if (doReload(connection)) {
                InputSource inputSource = new InputSource(connection.getInputStream());
                DocumentBuilderFactory factory = new DocumentBuilderFactoryImpl();
                this.document = factory.newDocumentBuilder().parse(inputSource);
            }
            return this.document;
        }
    }
public static int[] sortAscending(int input[]) {
        int[] order = new int[input.length];
        for (int i = 0; i < order.length; i++) order[i] = i;
        for (int i = input.length; --i >= 0; ) {
            for (int j = 0; j < i; j++) {
                if (input[j] > input[j + 1]) {
                    int mem = input[j];
                    input[j] = input[j + 1];
                    input[j + 1] = mem;
                    int id = order[j];
                    order[j] = order[j + 1];
                    order[j + 1] = id;
                }
            }
        }
        return order;
    }
public static int[] sortAscending(float input[]) {
        int[] order = new int[input.length];
        for (int i = 0; i < order.length; i++) order[i] = i;
        for (int i = input.length; --i >= 0; ) {
            for (int j = 0; j < i; j++) {
                if (input[j] > input[j + 1]) {
                    float mem = input[j];
                    input[j] = input[j + 1];
                    input[j + 1] = mem;
                    int id = order[j];
                    order[j] = order[j + 1];
                    order[j + 1] = id;
                }
            }
        }
        return order;
    }
public static int[] sortDescending(int input[]) {
        int[] order = new int[input.length];
        for (int i = 0; i < order.length; i++) order[i] = i;
        for (int i = input.length; --i >= 0; ) {
            for (int j = 0; j < i; j++) {
                if (input[j] < input[j + 1]) {
                    int mem = input[j];
                    input[j] = input[j + 1];
                    input[j + 1] = mem;
                    int id = order[j];
                    order[j] = order[j + 1];
                    order[j + 1] = id;
                }
            }
        }
        return order;
    }
public static int[] sortDescending(float input[]) {
        int[] order = new int[input.length];
        for (int i = 0; i < order.length; i++) order[i] = i;
        for (int i = input.length; --i >= 0; ) {
            for (int j = 0; j < i; j++) {
                if (input[j] < input[j + 1]) {
                    float mem = input[j];
                    input[j] = input[j + 1];
                    input[j + 1] = mem;
                    int id = order[j];
                    order[j] = order[j + 1];
                    order[j + 1] = id;
                }
            }
        }
        return order;
    }
public static int[] sortAscending(double input[]) {
        int[] order = new int[input.length];
        for (int i = 0; i < order.length; i++) order[i] = i;
        for (int i = input.length; --i >= 0; ) {
            for (int j = 0; j < i; j++) {
                if (input[j] > input[j + 1]) {
                    double mem = input[j];
                    input[j] = input[j + 1];
                    input[j + 1] = mem;
                    int id = order[j];
                    order[j] = order[j + 1];
                    order[j + 1] = id;
                }
            }
        }
        return order;
    }