semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public void process(int branch, int level) {
        Pattern p1 = Pattern.compile("<DIV class=\"treeline\">([^<]*)");
        Pattern p = Pattern.compile("<a href=\"javascript:checkBranch\\(([0-9]+), 'true'\\)\">([^<]*)</a>");
        Matcher m, m1;
        URL url;
        HttpURLConnection conn;
        try {
            url = new URL("http://cri-srv-ade.insa-toulouse.fr:8080/ade/standard/gui/tree.jsp?branchId=" + branch + "&expand=false&forceLoad=false&reload=false&scroll=0");
            conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.setDoOutput(true);
            conn.setDoInput(true);
            conn.setRequestProperty("Cookie", sessionId);
            BufferedReader i = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            boolean doAdd = false;
            while ((line = i.readLine()) != null) {
                m1 = p1.matcher(line);
                m = p.matcher(line);
                if (m1.find()) {
                    if (m1.group(1).equals(createIdent(level))) {
                        doAdd = true;
                    } else {
                        doAdd = false;
                    }
                }
                if (m.find()) {
                    if (doAdd) {
                        trainee.add(new Node(Integer.parseInt(m.group(1)), m.group(2)));
                        System.out.println(m.group(1) + " - " + m.group(2));
                    }
                }
            }
            url = new URL("http://cri-srv-ade.insa-toulouse.fr:8080/ade/standard/gui/tree.jsp?branchId=" + branch + "&expand=false&forceLoad=false&reload=false&scroll=0");
        } catch (Exception e2) {
            e2.printStackTrace();
        }
    }
byte[] loadUrlByteArray(String szName, int offset, int size) {
        byte[] baBuffer = new byte[size];
        try {
            URL url = new URL(waba.applet.Applet.currentApplet.getCodeBase(), szName);
            try {
                InputStream file = url.openStream();
                if (size == 0) {
                    int n = file.available();
                    baBuffer = new byte[n - offset];
                }
                DataInputStream dataFile = new DataInputStream(file);
                try {
                    dataFile.skip(offset);
                    dataFile.readFully(baBuffer);
                } catch (EOFException e) {
                    System.err.print(e.getMessage());
                }
                file.close();
            } catch (IOException e) {
                System.err.print(e.getMessage());
            }
        } catch (MalformedURLException e) {
            System.err.print(e.getMessage());
        }
        return baBuffer;
    }
protected void execute(Context context) throws java.lang.Exception {
            Connection c = null;
            Statement s = null;
            Integer check = context.getValueAsInteger("Total");
            System.err.println("In BuyWidget.execute()");
            try {
                c = context.getConnection();
                c.setAutoCommit(false);
                s = c.createStatement();
                int total = computeCheckoutTotal(context, s);
                if (check == null) {
                    throw new Exception("Shouldn't: No total?");
                }
                if (check.intValue() != total) {
                    throw new Exception("Shouldn't: Basket changed? " + "total was " + total + "; checksum was " + check);
                }
                StringBuffer q = new StringBuffer("select BIDSTATE.Bid, BIDSTATE.Amount, " + "BIDSTATE.QShipping, BIDSTATE.QInsure " + "from BID, BIDSTATE " + "where  BIDSTATE.Bid = BID.Bid " + "and ( BIDSTATE.BidStatus = 0 " + "or BIDSTATE.BidStatus = 15) " + "and BID.Customer = ");
                q.append(context.get("customer"));
                q.append(" and bidstate.bidstate =  " + "( select max( bidstate.bidstate) " + "from bidstate " + "where bid = bid.bid) ");
                System.err.println(q.toString());
                Contexts rows = new RSContexts(s.executeQuery(q.toString()));
                Enumeration e = rows.elements();
                while (e.hasMoreElements()) {
                    Context row = (Context) e.nextElement();
                    row.merge((Map) context);
                    row.put("Username", context.get(ConnectionPool.DBUSERMAGICTOKEN));
                    row.put("BidStatus", BidStatus.OFFER);
                    s.executeUpdate(bidStateInsert(row));
                    s.execute(bidPrivateInsert(context, row));
                }
                c.commit();
            } catch (Exception any) {
                c.rollback();
                throw new DataStoreException("Your card will not be debited: " + any.getMessage());
            } finally {
                try {
                    if (s != null) {
                        s.close();
                    }
                    if (c != null) {
                        context.releaseConnection(c);
                    }
                } catch (SQLException sex) {
                } catch (DataStoreException dse) {
                }
            }
            context.put(REDIRECTMAGICTOKEN, "account");
        }
protected String getPostRequestContent(String urlText, String postParam) throws Exception {
        URL url = new URL(urlText);
        HttpURLConnection urlcon = (HttpURLConnection) url.openConnection();
        urlcon.setRequestMethod("POST");
        urlcon.setUseCaches(false);
        urlcon.setDoOutput(true);
        PrintStream ps = new PrintStream(urlcon.getOutputStream());
        ps.print(postParam);
        ps.close();
        urlcon.connect();
        BufferedReader reader = new BufferedReader(new InputStreamReader(urlcon.getInputStream()));
        String line = reader.readLine();
        reader.close();
        urlcon.disconnect();
        return line;
    }
@Test
    public void testFromFile() throws IOException {
        File temp = File.createTempFile("fannj_", ".tmp");
        temp.deleteOnExit();
        IOUtils.copy(this.getClass().getResourceAsStream("xor_float.net"), new FileOutputStream(temp));
        Fann fann = new Fann(temp.getPath());
        assertEquals(2, fann.getNumInputNeurons());
        assertEquals(1, fann.getNumOutputNeurons());
        assertEquals(-1f, fann.run(new float[] { -1, -1 })[0], .2f);
        assertEquals(1f, fann.run(new float[] { -1, 1 })[0], .2f);
        assertEquals(1f, fann.run(new float[] { 1, -1 })[0], .2f);
        assertEquals(-1f, fann.run(new float[] { 1, 1 })[0], .2f);
        fann.close();
    }
InputStream selectSource(String item) {
        if (item.endsWith(".pls")) {
            item = fetch_pls(item);
            if (item == null) return null;
        } else if (item.endsWith(".m3u")) {
            item = fetch_m3u(item);
            if (item == null) return null;
        }
        if (!item.endsWith(".ogg")) {
            return null;
        }
        InputStream is = null;
        URLConnection urlc = null;
        try {
            URL url = null;
            if (running_as_applet) url = new URL(getCodeBase(), item); else url = new URL(item);
            urlc = url.openConnection();
            is = urlc.getInputStream();
            current_source = url.getProtocol() + "://" + url.getHost() + ":" + url.getPort() + url.getFile();
        } catch (Exception ee) {
            System.err.println(ee);
        }
        if (is == null && !running_as_applet) {
            try {
                is = new FileInputStream(System.getProperty("user.dir") + System.getProperty("file.separator") + item);
                current_source = null;
            } catch (Exception ee) {
                System.err.println(ee);
            }
        }
        if (is == null) return null;
        System.out.println("Select: " + item);
        {
            boolean find = false;
            for (int i = 0; i < cb.getItemCount(); i++) {
                String foo = (String) (cb.getItemAt(i));
                if (item.equals(foo)) {
                    find = true;
                    break;
                }
            }
            if (!find) {
                cb.addItem(item);
            }
        }
        int i = 0;
        String s = null;
        String t = null;
        udp_port = -1;
        udp_baddress = null;
        while (urlc != null && true) {
            s = urlc.getHeaderField(i);
            t = urlc.getHeaderFieldKey(i);
            if (s == null) break;
            i++;
            if (t != null && t.equals("udp-port")) {
                try {
                    udp_port = Integer.parseInt(s);
                } catch (Exception ee) {
                    System.err.println(ee);
                }
            } else if (t != null && t.equals("udp-broadcast-address")) {
                udp_baddress = s;
            }
        }
        return is;
    }
String fetch_pls(String pls) {
        InputStream pstream = null;
        if (pls.startsWith("http://")) {
            try {
                URL url = null;
                if (running_as_applet) url = new URL(getCodeBase(), pls); else url = new URL(pls);
                URLConnection urlc = url.openConnection();
                pstream = urlc.getInputStream();
            } catch (Exception ee) {
                System.err.println(ee);
                return null;
            }
        }
        if (pstream == null && !running_as_applet) {
            try {
                pstream = new FileInputStream(System.getProperty("user.dir") + System.getProperty("file.separator") + pls);
            } catch (Exception ee) {
                System.err.println(ee);
                return null;
            }
        }
        String line = null;
        while (true) {
            try {
                line = readline(pstream);
            } catch (Exception e) {
            }
            if (line == null) break;
            if (line.startsWith("File1=")) {
                byte[] foo = line.getBytes();
                int i = 6;
                for (; i < foo.length; i++) {
                    if (foo[i] == 0x0d) break;
                }
                return line.substring(6, i);
            }
        }
        return null;
    }
String fetch_m3u(String m3u) {
        InputStream pstream = null;
        if (m3u.startsWith("http://")) {
            try {
                URL url = null;
                if (running_as_applet) url = new URL(getCodeBase(), m3u); else url = new URL(m3u);
                URLConnection urlc = url.openConnection();
                pstream = urlc.getInputStream();
            } catch (Exception ee) {
                System.err.println(ee);
                return null;
            }
        }
        if (pstream == null && !running_as_applet) {
            try {
                pstream = new FileInputStream(System.getProperty("user.dir") + System.getProperty("file.separator") + m3u);
            } catch (Exception ee) {
                System.err.println(ee);
                return null;
            }
        }
        String line = null;
        while (true) {
            try {
                line = readline(pstream);
            } catch (Exception e) {
            }
            if (line == null) break;
            return line;
        }
        return null;
    }
void loadPlaylist() {
        if (running_as_applet) {
            String s = null;
            for (int i = 0; i < 10; i++) {
                s = getParameter("jorbis.player.play." + i);
                if (s == null) break;
                playlist.addElement(s);
            }
        }
        if (playlistfile == null) {
            return;
        }
        try {
            InputStream is = null;
            try {
                URL url = null;
                if (running_as_applet) url = new URL(getCodeBase(), playlistfile); else url = new URL(playlistfile);
                URLConnection urlc = url.openConnection();
                is = urlc.getInputStream();
            } catch (Exception ee) {
            }
            if (is == null && !running_as_applet) {
                try {
                    is = new FileInputStream(System.getProperty("user.dir") + System.getProperty("file.separator") + playlistfile);
                } catch (Exception ee) {
                }
            }
            if (is == null) return;
            while (true) {
                String line = readline(is);
                if (line == null) break;
                byte[] foo = line.getBytes();
                for (int i = 0; i < foo.length; i++) {
                    if (foo[i] == 0x0d) {
                        line = new String(foo, 0, i);
                        break;
                    }
                }
                playlist.addElement(line);
            }
        } catch (Exception e) {
            System.out.println(e);
        }
    }
private long getRecordedSessionLength() {
        long lRet = -1;
        String strLength = this.applet.getParameter(Constants.PLAYBACK_MEETING_LENGTH_PARAM);
        if (null != strLength) {
            lRet = (new Long(strLength)).longValue();
        } else {
            Properties recProps = new Properties();
            try {
                URL urlProps = new URL(applet.getDocumentBase(), Constants.RECORDED_SESSION_INFO_PROPERTIES);
                recProps.load(urlProps.openStream());
                lRet = (new Long(recProps.getProperty(Constants.PLAYBACK_MEETING_LENGTH_PARAM))).longValue();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return lRet;
    }
private void saveScore(int score) {
        String name = JOptionPane.showInputDialog(this, "Skriv navn for å komme på highscorelisten!", "Lagre score!", JOptionPane.INFORMATION_MESSAGE);
        URL url;
        try {
            url = new URL("http://129.177.17.51:8080/GuestBook/TheOnlyServlet?name=" + name + "&score=" + score);
            URLConnection urlConnection = url.openConnection();
            urlConnection.connect();
            urlConnection.getInputStream();
            BrowserControl.openUrl("http://129.177.17.51:8080/GuestBook/TheOnlyServlet");
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
private void copyParseFileToCodeFile() throws IOException {
        InputStream in = new FileInputStream(new File(filenameParse));
        OutputStream out = new FileOutputStream(new File(filenameMisc));
        byte[] buffer = new byte[1024];
        int length;
        while ((length = in.read(buffer)) > 0) out.write(buffer, 0, length);
        in.close();
        out.close();
    }
private long getNextHighValue() throws Exception {
            Connection con = null;
            PreparedStatement psGetHighValue = null;
            PreparedStatement psUpdateHighValue = null;
            ResultSet rs = null;
            long high = -1L;
            int isolation = -1;
            DBOperation dbo = factory.createDBOperation(POOL_NAME);
            try {
                con = dbo.getConnection();
                psGetHighValue = con.prepareStatement(strGetHighValue);
                psGetHighValue.setString(1, this.name);
                for (rs = psGetHighValue.executeQuery(); rs.next(); ) {
                    high = rs.getLong("high");
                }
                psUpdateHighValue = con.prepareStatement(strUpdateHighValue);
                psUpdateHighValue.setLong(1, high + 1L);
                psUpdateHighValue.setString(2, this.name);
                psUpdateHighValue.executeUpdate();
            } catch (SQLException e) {
                if (con != null) {
                    con.rollback();
                }
                throw e;
            } finally {
                if (psUpdateHighValue != null) {
                    psUpdateHighValue.close();
                }
                close(dbo, psGetHighValue, rs);
            }
            return high;
        }
public static boolean encodeFileToFile(String infile, String outfile) {
        boolean success = false;
        java.io.InputStream in = null;
        java.io.OutputStream out = null;
        try {
            in = new Base64.B64InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)), Base64.ENCODE);
            out = new java.io.BufferedOutputStream(new java.io.FileOutputStream(outfile));
            byte[] buffer = new byte[65536];
            int read = -1;
            while ((read = in.read(buffer)) >= 0) {
                out.write(buffer, 0, read);
            }
            success = true;
        } catch (java.io.IOException exc) {
            exc.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (Exception exc) {
            }
            try {
                out.close();
            } catch (Exception exc) {
            }
        }
        return success;
    }
public static boolean decodeFileToFile(String infile, String outfile) {
        boolean success = false;
        java.io.InputStream in = null;
        java.io.OutputStream out = null;
        try {
            in = new Base64.B64InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)), Base64.DECODE);
            out = new java.io.BufferedOutputStream(new java.io.FileOutputStream(outfile));
            byte[] buffer = new byte[65536];
            int read = -1;
            while ((read = in.read(buffer)) >= 0) {
                out.write(buffer, 0, read);
            }
            success = true;
        } catch (java.io.IOException exc) {
            exc.printStackTrace();
        } finally {
            try {
                in.close();
            } catch (Exception exc) {
            }
            try {
                out.close();
            } catch (Exception exc) {
            }
        }
        return success;
    }
public void criarQuestaoDiscursiva(QuestaoDiscursiva q) throws SQLException {
        PreparedStatement stmt = null;
        String sql = "INSERT INTO discursiva (id_questao,gabarito) VALUES (?,?)";
        try {
            stmt = conexao.prepareStatement(sql);
            stmt.setInt(1, q.getIdQuestao());
            stmt.setString(2, q.getGabarito());
            stmt.executeUpdate();
            conexao.commit();
        } catch (SQLException e) {
            conexao.rollback();
            throw e;
        }
    }
@Override
    public void alterar(QuestaoDiscursiva q) throws Exception {
        System.out.println("ALTERAR " + q.getIdQuestao());
        PreparedStatement stmt = null;
        String sql = "UPDATE questao SET id_disciplina=?, enunciado=?, grau_dificuldade=? WHERE id_questao=?";
        try {
            stmt = conexao.prepareStatement(sql);
            stmt.setInt(1, q.getDisciplina().getIdDisciplina());
            stmt.setString(2, q.getEnunciado());
            stmt.setString(3, q.getDificuldade().name());
            stmt.setInt(4, q.getIdQuestao());
            stmt.executeUpdate();
            conexao.commit();
            alterarQuestaoDiscursiva(q);
        } catch (SQLException e) {
            conexao.rollback();
            throw e;
        }
    }
public void alterarQuestaoDiscursiva(QuestaoDiscursiva q) throws SQLException {
        PreparedStatement stmt = null;
        String sql = "UPDATE discursiva SET  gabarito=? WHERE id_questao=?";
        try {
            stmt = conexao.prepareStatement(sql);
            stmt.setString(1, q.getGabarito());
            stmt.setInt(2, q.getIdQuestao());
            stmt.executeUpdate();
            conexao.commit();
        } catch (SQLException e) {
            conexao.rollback();
            throw e;
        }
    }
@Override
    public void excluir(QuestaoDiscursiva q) throws Exception {
        PreparedStatement stmt = null;
        String sql = "DELETE FROM questao WHERE id_questao=?";
        try {
            stmt = conexao.prepareStatement(sql);
            stmt.setInt(1, q.getIdQuestao());
            stmt.executeUpdate();
            conexao.commit();
        } catch (SQLException e) {
            conexao.rollback();
            throw e;
        }
    }
protected Drawing loadDrawing(ProgressIndicator progress) throws IOException {
        Drawing drawing = createDrawing();
        if (getParameter("datafile") != null) {
            URL url = new URL(getDocumentBase(), getParameter("datafile"));
            URLConnection uc = url.openConnection();
            if (uc instanceof HttpURLConnection) {
                ((HttpURLConnection) uc).setUseCaches(false);
            }
            int contentLength = uc.getContentLength();
            InputStream in = uc.getInputStream();
            try {
                if (contentLength != -1) {
                    in = new BoundedRangeInputStream(in);
                    ((BoundedRangeInputStream) in).setMaximum(contentLength + 1);
                    progress.setProgressModel((BoundedRangeModel) in);
                    progress.setIndeterminate(false);
                }
                BufferedInputStream bin = new BufferedInputStream(in);
                bin.mark(512);
                IOException formatException = null;
                for (InputFormat format : drawing.getInputFormats()) {
                    try {
                        bin.reset();
                    } catch (IOException e) {
                        uc = url.openConnection();
                        in = uc.getInputStream();
                        in = new BoundedRangeInputStream(in);
                        ((BoundedRangeInputStream) in).setMaximum(contentLength + 1);
                        progress.setProgressModel((BoundedRangeModel) in);
                        bin = new BufferedInputStream(in);
                        bin.mark(512);
                    }
                    try {
                        bin.reset();
                        format.read(bin, drawing, true);
                        formatException = null;
                        break;
                    } catch (IOException e) {
                        formatException = e;
                    }
                }
                if (formatException != null) {
                    throw formatException;
                }
            } finally {
                in.close();
            }
        }
        return drawing;
    }
public void save(UploadedFile file, Long student, Long activity) {
        File destiny = new File(fileFolder, student + "_" + activity + "_" + file.getFileName());
        try {
            IOUtils.copy(file.getFile(), new FileOutputStream(destiny));
        } catch (IOException e) {
            throw new RuntimeException("Erro ao copiar o arquivo.", e);
        }
    }
private List<Intrebare> citesteIntrebari() throws IOException {
        ArrayList<Intrebare> intrebari = new ArrayList<Intrebare>();
        try {
            URL url = new URL(getCodeBase(), "../intrebari.txt");
            BufferedReader reader = new BufferedReader(new InputStreamReader((url.openStream())));
            String intrebare;
            while ((intrebare = reader.readLine()) != null) {
                Collection<String> raspunsuri = new ArrayList<String>();
                Collection<String> predicate = new ArrayList<String>();
                String raspuns = "";
                while (!"".equals(raspuns = reader.readLine())) {
                    raspunsuri.add(raspuns);
                    predicate.add(reader.readLine());
                }
                Intrebare i = new Intrebare(intrebare, raspunsuri.toArray(new String[raspunsuri.size()]), predicate.toArray(new String[predicate.size()]));
                intrebari.add(i);
            }
        } catch (ArgumentExcetpion e) {
            e.printStackTrace();
        }
        return intrebari;
    }