semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public ArrayList loadData(String address) {
        URL url;
        BufferedReader bf_in = null;
        ArrayList a = new ArrayList();
        String line;
        try {
            url = new URL(address);
            bf_in = new BufferedReader(new InputStreamReader(url.openStream()));
            while (((line = bf_in.readLine()) != null)) {
                if (line.startsWith("Date")) {
                    continue;
                }
                if (line != null && line.length() > 0) {
                    a.add(line);
                }
            }
            bf_in.close();
        } catch (Exception e) {
            System.out.println("StockValumeHistory:loadData:Error:" + e);
        }
        return a;
    }
protected InputSource getInputSource(String pReferencingSystemId, String pURI) throws SAXException {
        URL url = null;
        if (pReferencingSystemId != null) {
            try {
                url = new URL(new URL(pReferencingSystemId), pURI);
            } catch (MalformedURLException e) {
            }
            if (url == null) {
                try {
                    url = new File(new File(pReferencingSystemId).getParentFile(), pURI).toURL();
                } catch (MalformedURLException e) {
                }
            }
        }
        if (url == null) {
            try {
                url = new URL(pURI);
            } catch (MalformedURLException e) {
                try {
                    url = new File(pURI).toURL();
                } catch (MalformedURLException f) {
                    throw new SAXException("Failed to parse the URI " + pURI);
                }
            }
        }
        try {
            InputSource isource = new InputSource(url.openStream());
            isource.setSystemId(url.toString());
            return isource;
        } catch (IOException e) {
            throw new SAXException("Failed to open the URL " + url, e);
        }
    }
public static void upLoadFile(File sourceFile, File targetFile) throws IOException {
        FileChannel inChannel = null;
        FileChannel outChannel = null;
        try {
            inChannel = new FileInputStream(sourceFile).getChannel();
            outChannel = new FileOutputStream(targetFile).getChannel();
            inChannel.transferTo(0, inChannel.size(), outChannel);
        } finally {
            try {
                if (inChannel != null) {
                    inChannel.close();
                }
                if (outChannel != null) {
                    outChannel.close();
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
public static String crypt(String target) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        MessageDigest md = MessageDigest.getInstance("MD5");
        md.update(target.getBytes("UTF-16"));
        BigInteger res = new BigInteger(1, md.digest(key.getBytes()));
        return res.toString(16);
    }
public static String cryptSha(String target) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        MessageDigest md = MessageDigest.getInstance("SHA");
        md.update(target.getBytes("UTF-16"));
        BigInteger res = new BigInteger(1, md.digest(key.getBytes()));
        return res.toString(16);
    }
public static void main(String args[]) {
        int summ = 0;
        int temp = 0;
        int[] a1 = { 0, 6, -7, -7, 61, 8, 20, 0, 8, 3, 6, 2, 7, 99, 0, 23, 12, 7, 9, 5, 33, 1, 3, 99, 99, 61, 99, 99, 99, 61, 61, 61, -3, -3, -3, -3 };
        for (int j = 0; j < (a1.length * a1.length); j++) {
            for (int i = 0; i < a1.length - 1; i++) {
                if (a1[i] > a1[i + 1]) {
                    temp = a1[i];
                    a1[i] = a1[i + 1];
                    a1[i + 1] = temp;
                }
            }
        }
        for (int i = 0; i < a1.length; i++) {
            System.out.print(" " + a1[i]);
        }
        int min = 0;
        int max = 0;
        summ = (a1[1]) + (a1[a1.length - 1]);
        for (int i = 0; i < a1.length; i++) {
            if (a1[i] > a1[0] && a1[i] != a1[0]) {
                min = a1[i];
                break;
            }
        }
        for (int i = a1.length - 1; i > 0; i--) {
            if (a1[i] < a1[a1.length - 1] & a1[i] != a1[a1.length - 1]) {
                max = a1[i];
                break;
            }
        }
        System.out.println();
        System.out.print("summa 2 min N 2 max = " + summ);
        System.out.println(min);
        System.out.println(max);
        System.out.println("summa 2 min N 2 max = " + (min + max));
    }
public void addRegisterInfo(HttpServletRequest request) throws ApplicationException {
        String[] pids = request.getParameterValues("pid");
        if (pids == null || pids.length <= 0) throw new ApplicationException("��ѡ��Ҫ���Ĳ�Ʒ");
        RegisterDao registerDao = new RegisterDao();
        Register register = registerDao.findPojoById(StrFun.getString(request, "rid"), Register.class);
        if (register.audit) throw new ApplicationException("��������Ѿ���ˣ��������µ���Ʒ");
        DBConnect dbc = null;
        Connection conn = null;
        try {
            dbc = DBConnect.createDBConnect();
            conn = dbc.getConnection();
            conn.setAutoCommit(false);
            for (String pid : pids) {
                RegisterInfo pd = new RegisterInfo();
                pd.rid = StrFun.getInt(request, "rid");
                pd.pid = Integer.parseInt(pid);
                pd.productName = StrFun.getString(request, "productName_" + pid);
                pd.regAmount = StrFun.getInt(request, "regAmount_" + pid);
                pd.regPrice = StrFun.getInt(request, "regPrice_" + pid);
                pd.regSalePrice = StrFun.getInt(request, "regSalePrice_" + pid);
                pd.userNo = ServerUtil.getUserFromSession(request).userNo;
                if (pd.regAmount <= 0) throw new ApplicationException("�����������Ϊ��");
                String sql = "insert into SS_RegisterInfo " + "(pid, rid, productName, regAmount, regPrice, regSalePrice, userNo) " + "values(" + "'" + pd.pid + "', " + "'" + pd.rid + "', " + "'" + pd.productName + "', " + "'" + pd.regAmount + "', " + "'" + pd.regPrice + "', " + "'" + pd.regSalePrice + "', " + "'" + pd.userNo + "' " + ")";
                conn.createStatement().executeUpdate(sql);
            }
            conn.commit();
        } catch (Exception e) {
            e.printStackTrace();
            if (conn != null) {
                try {
                    conn.rollback();
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new ApplicationException(e.getMessage(), e);
        } finally {
            if (dbc != null) try {
                dbc.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
public static void loadProperties() {
        try {
            URL url = ClassLoader.getSystemResource("OpenDarkRoom.lang.en.properties");
            localization.load(url.openStream());
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            FileInputStream is = new FileInputStream(userDir + "OpenDarkRoom.properties");
            preferences.load(is);
        } catch (FileNotFoundException e) {
            log.warn("Preferences file " + userDir + "OpenDarkRoom.properties not found, loading defaults");
            loadDefaultPreferences();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
private static void loadDefaultPreferences() {
        try {
            URL url = ClassLoader.getSystemResource("OpenDarkRoom.defaults.properties");
            preferences.load(url.openStream());
        } catch (FileNotFoundException e) {
            log.error("Default preferences file not found");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
public String makeLeoNounCall(String noun) {
        String ret = "";
        StringBuffer buf = new StringBuffer();
        try {
            URL url = new URL("http://dict.leo.org" + noun);
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream(), Charset.forName("ISO8859_1")));
            String inputLine;
            boolean display = false;
            while ((inputLine = in.readLine()) != null) {
                if (inputLine.contains("contentholder")) {
                    display = true;
                }
                if (display) buf.append(inputLine);
            }
            ret = FilterFunctions.findEndTag("<td", buf.toString());
            sleepRandomTime();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return ret;
    }
@Override
    public void sortArray(int[] array) {
        boolean sorted = false;
        while (sorted == false) {
            sorted = true;
            for (int i = 0; i <= array.length - 2; i++) {
                if (array[i] > array[i + 1]) {
                    int temp = array[i];
                    array[i] = array[i + 1];
                    array[i + 1] = temp;
                    sorted = false;
                }
            }
        }
    }
public void testStorageString() throws Exception {
        TranslationResponseInMemory r = new TranslationResponseInMemory(2048, "UTF-8");
        r.addText("This is an example");
        r.addText(" and another one.");
        assertEquals("This is an example and another one.", r.getText());
        InputStream input = r.getInputStream();
        StringWriter writer = new StringWriter();
        try {
            IOUtils.copy(input, writer, "UTF-8");
        } finally {
            input.close();
            writer.close();
        }
        assertEquals("This is an example and another one.", writer.toString());
        try {
            r.getOutputStream();
            fail("Once addText() is used the text is stored as a String and you cannot use getOutputStream anymore");
        } catch (IOException e) {
        }
        try {
            r.getWriter();
            fail("Once addText() is used the text is stored as a String and you cannot use getOutputStream anymore");
        } catch (IOException e) {
        }
        r.setEndState(ResponseStateOk.getInstance());
        assertTrue(r.hasEnded());
    }
public void testStorageByteArray() throws Exception {
        TranslationResponseInMemory r = new TranslationResponseInMemory(2048, "UTF-8");
        {
            OutputStream output = r.getOutputStream();
            output.write("This is an example".getBytes("UTF-8"));
            output.write(" and another one.".getBytes("UTF-8"));
            assertEquals("This is an example and another one.", r.getText());
        }
        {
            InputStream input = r.getInputStream();
            StringWriter writer = new StringWriter();
            try {
                IOUtils.copy(input, writer, "UTF-8");
            } finally {
                input.close();
                writer.close();
            }
            assertEquals("This is an example and another one.", writer.toString());
        }
        {
            OutputStream output = r.getOutputStream();
            output.write(" and another line".getBytes("UTF-8"));
            assertEquals("This is an example and another one. and another line", r.getText());
        }
        {
            Writer output = r.getWriter();
            output.write(" and write some more");
            assertEquals("This is an example and another one. and another line and write some more", r.getText());
        }
        {
            r.addText(" and even more.");
            assertEquals("This is an example and another one. and another line and write some more and even more.", r.getText());
        }
        assertFalse(r.hasEnded());
        r.setEndState(ResponseStateOk.getInstance());
        assertTrue(r.hasEnded());
        try {
            r.getOutputStream();
            fail("Previous line should throw IOException as result closed.");
        } catch (IOException e) {
        }
        try {
            r.getWriter();
            fail("Previous line should throw IOException as result closed.");
        } catch (IOException e) {
        }
    }
public void testStorageStringWriter() throws Exception {
        TranslationResponseInMemory r = new TranslationResponseInMemory(2048, "UTF-8");
        {
            Writer w = r.getWriter();
            w.write("This is an example");
            w.write(" and another one.");
            w.flush();
            assertEquals("This is an example and another one.", r.getText());
        }
        {
            InputStream input = r.getInputStream();
            StringWriter writer = new StringWriter();
            try {
                IOUtils.copy(input, writer, "UTF-8");
            } finally {
                input.close();
                writer.close();
            }
            assertEquals("This is an example and another one.", writer.toString());
        }
        try {
            r.getOutputStream();
            fail("Is not allowed as you already called getWriter().");
        } catch (IOException e) {
        }
        {
            Writer output = r.getWriter();
            output.write(" and another line");
            output.write(" and write some more");
            assertEquals("This is an example and another one. and another line and write some more", r.getText());
        }
        {
            r.addText(" and some more.");
            assertEquals("This is an example and another one. and another line and write some more and some more.", r.getText());
        }
        r.setEndState(ResponseStateOk.getInstance());
        assertEquals(ResponseStateOk.getInstance(), r.getEndState());
        try {
            r.getWriter();
            fail("Previous line should throw IOException as result closed.");
        } catch (IOException e) {
        }
    }
@Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException {
        PrintWriter writer = null;
        InputStream is = null;
        FileOutputStream fos = null;
        try {
            writer = response.getWriter();
        } catch (IOException ex) {
            log(OctetStreamReader.class.getName() + "has thrown an exception: " + ex.getMessage());
        }
        String filename = request.getHeader("X-File-Name");
        try {
            is = request.getInputStream();
            fos = new FileOutputStream(new File(targetPath + filename));
            IOUtils.copy(is, fos);
            response.setStatus(HttpServletResponse.SC_OK);
            writer.print("{success: true}");
        } catch (FileNotFoundException ex) {
            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            writer.print("{success: false}");
            log(OctetStreamReader.class.getName() + "has thrown an exception: " + ex.getMessage());
        } catch (IOException ex) {
            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            writer.print("{success: false}");
            log(OctetStreamReader.class.getName() + "has thrown an exception: " + ex.getMessage());
        } finally {
            try {
                fos.close();
                is.close();
            } catch (IOException ignored) {
            }
        }
        writer.flush();
        writer.close();
    }
protected void doBackupOrganizeType() throws Exception {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet result = null;
        String strSelQuery = "SELECT organize_type_id,organize_type_name,width " + "FROM " + Common.ORGANIZE_TYPE_TABLE;
        String strInsQuery = "INSERT INTO " + Common.ORGANIZE_TYPE_B_TABLE + " " + "(version_no,organize_type_id,organize_type_name,width) " + "VALUES (?,?,?,?)";
        DBOperation dbo = factory.createDBOperation(POOL_NAME);
        try {
            try {
                con = dbo.getConnection();
                con.setAutoCommit(false);
                ps = con.prepareStatement(strSelQuery);
                result = ps.executeQuery();
                ps = con.prepareStatement(strInsQuery);
                while (result.next()) {
                    ps.setInt(1, this.versionNO);
                    ps.setString(2, result.getString("organize_type_id"));
                    ps.setString(3, result.getString("organize_type_name"));
                    ps.setInt(4, result.getInt("width"));
                    int resultCount = ps.executeUpdate();
                    if (resultCount != 1) {
                        con.rollback();
                        throw new CesSystemException("Organize_backup.doBackupOrganizeType(): ERROR Inserting data " + "in T_SYS_ORGANIZE_B_TYPE INSERT !! resultCount = " + resultCount);
                    }
                }
                con.commit();
            } catch (SQLException se) {
                con.rollback();
                throw new CesSystemException("Organize_backup.doBackupOrganizeType(): SQLException:  " + se);
            } finally {
                con.setAutoCommit(true);
                close(dbo, ps, result);
            }
        } catch (SQLException se) {
            throw new CesSystemException("Organize_backup.doBackupOrganizeType(): SQLException while committing or rollback");
        }
    }
protected void doBackupOrganizeTypeRelation() throws Exception {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet result = null;
        String strSelQuery = "SELECT parent_organize_type,child_organize_type " + "FROM " + Common.ORGANIZE_TYPE_RELATION_TABLE;
        String strInsQuery = "INSERT INTO " + Common.ORGANIZE_TYPE_RELATION_B_TABLE + " " + "(version_no,parent_organize_type,child_organize_type) " + "VALUES (?,?,?)";
        DBOperation dbo = factory.createDBOperation(POOL_NAME);
        try {
            try {
                con = dbo.getConnection();
                con.setAutoCommit(false);
                ps = con.prepareStatement(strSelQuery);
                result = ps.executeQuery();
                ps = con.prepareStatement(strInsQuery);
                while (result.next()) {
                    ps.setInt(1, this.versionNO);
                    ps.setString(2, result.getString("parent_organize_type"));
                    ps.setString(3, result.getString("child_organize_type"));
                    int resultCount = ps.executeUpdate();
                    if (resultCount != 1) {
                        con.rollback();
                        throw new CesSystemException("Organize_backup.doBackupOrganizeTypeRelation(): ERROR Inserting data " + "in T_SYS_ORGANIZE_TYPE_RELATION_B INSERT !! resultCount = " + resultCount);
                    }
                }
                con.commit();
            } catch (SQLException se) {
                con.rollback();
                throw new CesSystemException("Organize_backup.doBackupOrganizeTypeRelation(): SQLException:  " + se);
            } finally {
                con.setAutoCommit(true);
                close(dbo, ps, result);
            }
        } catch (SQLException se) {
            throw new CesSystemException("Organize_backup.doBackupOrganizeTypeRelation(): SQLException while committing or rollback");
        }
    }
protected void doBackupOrganize() throws Exception {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet result = null;
        String strSelQuery = "SELECT organize_id,organize_type_id,organize_name,organize_manager," + "organize_describe,work_type,show_order,position_x,position_y " + "FROM " + Common.ORGANIZE_TABLE;
        String strInsQuery = "INSERT INTO " + Common.ORGANIZE_B_TABLE + " " + "(version_no,organize_id,organize_type_id,organize_name,organize_manager," + "organize_describe,work_type,show_order,position_x,position_y) " + "VALUES (?,?,?,?,?,?,?,?,?,?)";
        DBOperation dbo = factory.createDBOperation(POOL_NAME);
        try {
            try {
                con = dbo.getConnection();
                con.setAutoCommit(false);
                ps = con.prepareStatement(strSelQuery);
                result = ps.executeQuery();
                ps = con.prepareStatement(strInsQuery);
                while (result.next()) {
                    ps.setInt(1, this.versionNO);
                    ps.setString(2, result.getString("organize_id"));
                    ps.setString(3, result.getString("organize_type_id"));
                    ps.setString(4, result.getString("organize_name"));
                    ps.setString(5, result.getString("organize_manager"));
                    ps.setString(6, result.getString("organize_describe"));
                    ps.setString(7, result.getString("work_type"));
                    ps.setInt(8, result.getInt("show_order"));
                    ps.setInt(9, result.getInt("position_x"));
                    ps.setInt(10, result.getInt("position_y"));
                    int resultCount = ps.executeUpdate();
                    if (resultCount != 1) {
                        con.rollback();
                        throw new CesSystemException("Organize_backup.doBackupOrganize(): ERROR Inserting data " + "in T_SYS_ORGANIZE_B INSERT !! resultCount = " + resultCount);
                    }
                }
                con.commit();
            } catch (SQLException se) {
                con.rollback();
                throw new CesSystemException("Organize_backup.doBackupOrganize(): SQLException:  " + se);
            } finally {
                con.setAutoCommit(true);
                close(dbo, ps, result);
            }
        } catch (SQLException se) {
            throw new CesSystemException("Organize_backup.doBackupOrganize(): SQLException while committing or rollback");
        }
    }
protected void doBackupOrganizeRelation() throws Exception {
        Connection con = null;
        PreparedStatement ps = null;
        ResultSet result = null;
        String strSelQuery = "SELECT organize_id,organize_type_id,child_id,child_type_id,remark " + "FROM " + Common.ORGANIZE_RELATION_TABLE;
        String strInsQuery = "INSERT INTO " + Common.ORGANIZE_RELATION_B_TABLE + " " + "(version_no,organize_id,organize_type,child_id,child_type,remark) " + "VALUES (?,?,?,?,?,?)";
        DBOperation dbo = factory.createDBOperation(POOL_NAME);
        try {
            try {
                con = dbo.getConnection();
                con.setAutoCommit(false);
                ps = con.prepareStatement(strSelQuery);
                result = ps.executeQuery();
                ps = con.prepareStatement(strInsQuery);
                while (result.next()) {
                    ps.setInt(1, this.versionNO);
                    ps.setString(2, result.getString("organize_id"));
                    ps.setString(3, result.getString("organize_type_id"));
                    ps.setString(4, result.getString("child_id"));
                    ps.setString(5, result.getString("child_type_id"));
                    ps.setString(6, result.getString("remark"));
                    int resultCount = ps.executeUpdate();
                    if (resultCount != 1) {
                        con.rollback();
                        throw new CesSystemException("Organize_backup.doBackupOrganizeRelation(): ERROR Inserting data " + "in T_SYS_ORGANIZE_RELATION_B INSERT !! resultCount = " + resultCount);
                    }
                }
                con.commit();
            } catch (SQLException se) {
                con.rollback();
                throw new CesSystemException("Organize_backup.doBackupOrganizeRelation(): SQLException:  " + se);
            } finally {
                con.setAutoCommit(true);
                close(dbo, ps, result);
            }
        } catch (SQLException se) {
            throw new CesSystemException("Organize_backup.doBackupOrganizeRelation(): SQLException while committing or rollback");
        }
    }