semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public void saveUploadFiles(List uploadFiles) throws SQLException {
        Connection conn = AppLayerDatabase.getInstance().getPooledConnection();
        try {
            conn.setAutoCommit(false);
            Statement s = conn.createStatement();
            s.executeUpdate("DELETE FROM UPLOADFILES");
            s.close();
            s = null;
            PreparedStatement ps = conn.prepareStatement("INSERT INTO UPLOADFILES (" + "path,size,fnkey,enabled,state," + "uploadaddedtime,uploadstartedtime,uploadfinishedtime,retries,lastuploadstoptime,gqid," + "sharedfilessha) " + "VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");
            for (Iterator i = uploadFiles.iterator(); i.hasNext(); ) {
                FrostUploadItem ulItem = (FrostUploadItem) i.next();
                int ix = 1;
                ps.setString(ix++, ulItem.getFile().getPath());
                ps.setLong(ix++, ulItem.getFileSize());
                ps.setString(ix++, ulItem.getKey());
                ps.setBoolean(ix++, (ulItem.isEnabled() == null ? true : ulItem.isEnabled().booleanValue()));
                ps.setInt(ix++, ulItem.getState());
                ps.setLong(ix++, ulItem.getUploadAddedMillis());
                ps.setLong(ix++, ulItem.getUploadStartedMillis());
                ps.setLong(ix++, ulItem.getUploadFinishedMillis());
                ps.setInt(ix++, ulItem.getRetries());
                ps.setLong(ix++, ulItem.getLastUploadStopTimeMillis());
                ps.setString(ix++, ulItem.getGqIdentifier());
                ps.setString(ix++, (ulItem.getSharedFileItem() == null ? null : ulItem.getSharedFileItem().getSha()));
                ps.executeUpdate();
            }
            ps.close();
            conn.commit();
            conn.setAutoCommit(true);
        } catch (Throwable t) {
            logger.log(Level.SEVERE, "Exception during save", t);
            try {
                conn.rollback();
            } catch (Throwable t1) {
                logger.log(Level.SEVERE, "Exception during rollback", t1);
            }
            try {
                conn.setAutoCommit(true);
            } catch (Throwable t1) {
            }
        } finally {
            AppLayerDatabase.getInstance().givePooledConnection(conn);
        }
    }
HTTPValuePatternComponent(final String url, final long seed) throws IOException {
        seedRandom = new Random(seed);
        random = new ThreadLocal<Random>();
        final ArrayList<String> lineList = new ArrayList<String>(100);
        final URL parsedURL = new URL(url);
        final HttpURLConnection urlConnection = (HttpURLConnection) parsedURL.openConnection();
        final BufferedReader reader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
        try {
            while (true) {
                final String line = reader.readLine();
                if (line == null) {
                    break;
                }
                lineList.add(line);
            }
        } finally {
            reader.close();
        }
        if (lineList.isEmpty()) {
            throw new IOException(ERR_VALUE_PATTERN_COMPONENT_EMPTY_FILE.get());
        }
        lines = new String[lineList.size()];
        lineList.toArray(lines);
    }
public static void main(String[] args) throws Exception {
        TripleDES tdes = new TripleDES();
        StreamBlockReader reader = new StreamBlockReader(new FileInputStream("D:\\test.txt"));
        StreamBlockWriter writer = new StreamBlockWriter(new FileOutputStream("D:\\testTDESENC.txt"));
        SingleKey key = new SingleKey(new Block(128), "");
        key = new SingleKey(new Block("01011101110000101001100111001011101000001110111101001001101101101101100000011101100100110000101100001110000001111101001101001101"), "");
        Mode mode = new ECBTripleDESMode(tdes);
        tdes.encrypt(reader, writer, key, mode);
    }
public static String hash(String value) {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance(HASH_ALGORITHM);
        } catch (NoSuchAlgorithmException e) {
            throw new CryptoException(e);
        }
        try {
            md.update(value.getBytes(INPUT_ENCODING));
        } catch (UnsupportedEncodingException e) {
            throw new CryptoException(e);
        }
        return new BASE64Encoder().encode(md.digest());
    }
public static String getFurigana(String sentence) throws Exception {
        Log.d("--VOA--", "getFurigana START");
        sbFurigana = new StringBuffer();
        String urlStr = getYahooApiURL();
        urlStr = addSentence(urlStr, sentence);
        URL url = new URL(urlStr);
        URLConnection uc = url.openConnection();
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        dbf.setNamespaceAware(true);
        DocumentBuilder db = dbf.newDocumentBuilder();
        Log.d("--VOA--", uc.getURL().toString());
        InputStream is = uc.getInputStream();
        doc = db.parse(is);
        walkThrough();
        Log.d("--VOA--", "getFurigana END");
        return sbFurigana.toString();
    }
public static Document send(final String urlAddress) {
        Document responseMessage = null;
        try {
            URL url = new URL(urlAddress);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.setAllowUserInteraction(false);
            int response = connection.getResponseCode();
            if (response == HttpURLConnection.HTTP_OK) {
                String contentType = connection.getContentType();
                if (contentType != null && contentType.startsWith("text/html")) {
                    InputStream inputStream = connection.getInputStream();
                    responseMessage = XmlUtils.fromStream(inputStream);
                } else {
                    responseMessage = XmlUtils.newDocument();
                    Element responseElement = XmlUtils.createElement(responseMessage, "rsp");
                    Element messageElement = XmlUtils.createElement(responseElement, "message");
                    messageElement.setTextContent(String.valueOf(connection.getResponseCode()));
                    Element commentElement = XmlUtils.createElement(responseElement, "comment");
                    commentElement.setTextContent(contentType);
                }
            } else {
                responseMessage = XmlUtils.newDocument();
                Element responseElement = XmlUtils.createElement(responseMessage, "rsp");
                Element messageElement = XmlUtils.createElement(responseElement, "message");
                messageElement.setTextContent(String.valueOf(connection.getResponseCode()));
                Element commentElement = XmlUtils.createElement(responseElement, "comment");
                commentElement.setTextContent(connection.getResponseMessage());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return responseMessage;
    }
private void copy(File from, File to) throws FileNotFoundException, IOException {
        FileReader in;
        in = new FileReader(from);
        FileWriter out = new FileWriter(to);
        int c;
        while ((c = in.read()) != -1) out.write(c);
        in.close();
        out.close();
    }
public static void copyFile(File source, File destination) {
        if (!source.exists()) {
            return;
        }
        if ((destination.getParentFile() != null) && (!destination.getParentFile().exists())) {
            destination.getParentFile().mkdirs();
        }
        try {
            FileChannel srcChannel = new FileInputStream(source).getChannel();
            FileChannel dstChannel = new FileOutputStream(destination).getChannel();
            dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
            srcChannel.close();
            dstChannel.close();
        } catch (IOException ioe) {
            Logger.error(FileUtil.class, ioe.getMessage(), ioe);
        }
    }
public String expandTemplate(String target) throws IOException, HttpException {
        connect();
        try {
            HttpGet request = new HttpGet(contextPath + target);
            HttpResponse response = httpexecutor.execute(request, conn);
            TolvenLogger.info("Response: " + response.getStatusLine(), TemplateGen.class);
            disconnect();
            return EntityUtils.toString(response.getEntity());
        } finally {
            disconnect();
        }
    }
public void go() {
        DataOutputStream outStream = null;
        try {
            connection = (HttpURLConnection) url.openConnection();
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-Length", new Integer(sendData.length()).toString());
            connection.setRequestProperty("Content-type", "text/html");
            connection.setRequestProperty("User-Agent", "Pago HTTP cartridge");
            outStream = new DataOutputStream(connection.getOutputStream());
            outStream.writeBytes(sendData);
            System.out.println(1);
            InputStream is = connection.getInputStream();
            System.out.println(2);
            inReader = new BufferedReader(new InputStreamReader(is));
            String result;
            System.out.println(3);
            if ((result = inReader.readLine()) != null) {
                System.out.println(result);
            }
        } catch (IOException ioe) {
            ioe.printStackTrace();
            System.exit(0);
        } finally {
            try {
                if (outStream != null) outStream.close();
                if (inReader != null) inReader.close();
            } catch (IOException ioe) {
                System.err.println("Error closing Streams!");
                ioe.printStackTrace();
            }
            connection.disconnect();
        }
    }
public Coordinates geocode(Address address) {
        Coordinates geocoordinates = null;
        String web = YAHOOURL + "?appid=" + applicationId + "&location=" + createLocation(address);
        URL url;
        try {
            url = new URL(web);
            InputStream in = url.openStream();
            geocoordinates = YahooXmlReader.readConfig(in);
            in.close();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return geocoordinates;
    }
private String[] sendRequest(String url, String requestString) throws ClickatellException, IOException {
        String response = null;
        MessageFormat responseFormat = new MessageFormat("{0}: {1}");
        List idList = new LinkedList();
        try {
            log_.debug("sendRequest: posting : " + requestString + " to " + url);
            URL requestURL = new URL(url);
            URLConnection urlConn = requestURL.openConnection();
            urlConn.setDoInput(true);
            urlConn.setDoOutput(true);
            urlConn.setUseCaches(false);
            urlConn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
            PrintWriter pw = new PrintWriter(urlConn.getOutputStream());
            pw.print(requestString);
            pw.flush();
            pw.close();
            InputStream is = urlConn.getInputStream();
            BufferedReader responseReader = new BufferedReader(new InputStreamReader(is));
            while ((response = responseReader.readLine()) != null) {
                Object[] objs = responseFormat.parse(response);
                if ("ERR".equalsIgnoreCase((String) objs[0])) {
                    MessageFormat errorFormat = new MessageFormat("{0}: {1}, {2}");
                    Object[] errObjs = errorFormat.parse(response);
                    String errorNo = (String) errObjs[1];
                    String description = (String) errObjs[2];
                    throw new ClickatellException("Clickatell error. Error " + errorNo + ", " + description, Integer.parseInt(errorNo));
                }
                log_.debug("sendRequest: Got ID : " + ((String) objs[1]));
                idList.add(objs[1]);
            }
            responseReader.close();
        } catch (ParseException ex) {
            throw new ClickatellException("Unexpected response from Clickatell. : " + response, ClickatellException.ERROR_UNKNOWN);
        }
        return (String[]) idList.toArray(new String[idList.size()]);
    }
private void sendToServer(String fichaID, String respostas) throws FileNotFoundException, ParserConfigurationException, SAXException, IOException, URISyntaxException {
        ArrayList params = new ArrayList();
        params.add(new BasicNameValuePair("xml", respostas));
        params.add(new BasicNameValuePair("idForm", fichaID));
        URI uri = URIUtils.createURI("http", "172.20.9.144", 8080, "/PSFServer/SaveAnswers", URLEncodedUtils.format(params, "UTF-8"), null);
        HttpPost request = new HttpPost(uri);
        request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));
        HttpClient client = new DefaultHttpClient();
        HttpResponse httpResponse = client.execute(request);
        BufferedReader in = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));
        StringBuffer sb = new StringBuffer("");
        String line = "";
        String NL = System.getProperty("line.separator");
        while ((line = in.readLine()) != null) {
            sb.append(line + NL);
        }
        in.close();
        String resposta = sb.toString();
        if (resposta != null || resposta != "") {
            new DatabaseManager(this).getWritableDatabase().execSQL("delete from " + DatabaseManager.getTableDados());
        }
        backToMain();
    }
@SuppressWarnings("unchecked")
    public void handle(Map<String, Object> data, String urlPath) {
        try {
            URL url = new URL(urlPath);
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), "utf-8"));
            String line = null;
            CMGroup currentGroup = null;
            List<CMGroup> groups = (List<CMGroup>) data.get(CMConstants.GROUP);
            List<CMTag> tags = (List<CMTag>) data.get(CMConstants.TAG);
            List<CMTagGroup> tagGroups = (List<CMTagGroup>) data.get(CMConstants.TAG_GROUP);
            while ((line = reader.readLine()) != null) {
                CMGroup group = null;
                try {
                    group = FetchUtil.getCMGroup(line);
                } catch (Exception e) {
                    CMLog.getLogger(this).severe("getCMGroup error:" + line);
                }
                if (group != null) {
                    if (currentGroup != null) {
                        groups.add(currentGroup);
                    }
                    currentGroup = group;
                }
                CMTag tag = null;
                try {
                    tag = FetchUtil.getCMTag(line);
                } catch (Exception e) {
                    CMLog.getLogger(this).severe("getCMTag error:" + line);
                }
                if (tag != null) {
                    CMTagGroup tagGroup = new CMTagGroup();
                    tagGroup.setGroupName(currentGroup.getName());
                    tagGroup.setTagName(tag.getName());
                    tags.add(tag);
                    tagGroups.add(tagGroup);
                }
            }
            groups.add(currentGroup);
            reader.close();
        } catch (MalformedURLException e) {
            CMLog.getLogger(this).severe("GTagHandler error:" + e.getMessage());
            e.printStackTrace();
        } catch (IOException e) {
            CMLog.getLogger(this).severe("GTagHandler error:" + e.getMessage());
            e.printStackTrace();
        }
    }
private static File copyJarToPool(File file) {
        File outFile = new File(RizzToolConstants.TOOL_POOL_FOLDER.getAbsolutePath() + File.separator + file.getName());
        if (file != null && file.exists() && file.canRead()) {
            try {
                FileChannel inChan = new FileInputStream(file).getChannel();
                FileChannel outChan = new FileOutputStream(outFile).getChannel();
                inChan.transferTo(0, inChan.size(), outChan);
                return outFile;
            } catch (Exception ex) {
                RizzToolConstants.DEFAULT_LOGGER.error("Exception while copying jar file to tool pool [inFile=" + file.getAbsolutePath() + "] [outFile=" + outFile.getAbsolutePath() + ": " + ex);
            }
        } else {
            RizzToolConstants.DEFAULT_LOGGER.error("Could not copy jar file. File does not exist or can't read file. [inFile=" + file.getAbsolutePath() + "]");
        }
        return null;
    }
Bitmap downloadBitmap(String url) {
        final int IO_BUFFER_SIZE = 4 * 1024;
        final HttpClient client = (mode == Mode.NO_ASYNC_TASK) ? new DefaultHttpClient() : AndroidHttpClient.newInstance("Android");
        final HttpGet getRequest = new HttpGet(url);
        try {
            HttpResponse response = client.execute(getRequest);
            final int statusCode = response.getStatusLine().getStatusCode();
            if (statusCode != HttpStatus.SC_OK) {
                Log.w("ImageDownloader", "Error " + statusCode + " while retrieving bitmap from " + url);
                return null;
            }
            final HttpEntity entity = response.getEntity();
            if (entity != null) {
                InputStream inputStream = null;
                try {
                    inputStream = entity.getContent();
                    return BitmapFactory.decodeStream(new FlushedInputStream(inputStream));
                } finally {
                    if (inputStream != null) {
                        inputStream.close();
                    }
                    entity.consumeContent();
                }
            }
        } catch (IOException e) {
            getRequest.abort();
            Log.w(LOG_TAG, "I/O error while retrieving bitmap from " + url, e);
        } catch (IllegalStateException e) {
            getRequest.abort();
            Log.w(LOG_TAG, "Incorrect URL: " + url);
        } catch (Exception e) {
            getRequest.abort();
            Log.w(LOG_TAG, "Error while retrieving bitmap from " + url, e);
        } finally {
            if ((client instanceof AndroidHttpClient)) {
                ((AndroidHttpClient) client).close();
            }
        }
        return null;
    }
protected void loadConfigure() {
        try {
            confFile = System.getProperty("user.home");
            confFile = confFile + W.sepa + ".elm" + W.sepa + "vesma.conf";
            URL url = W.getResource(confFile);
            InputStream is = url.openStream();
            confDoc = W.loadDocumentFromInputStreamDOM(is);
            Element e = confDoc.getDocumentElement();
            Element ee = W.getChildByTagNameDOM(e, "rmiregistry");
            String s = W.getAttrDataDOM(ee, "enable");
            rmiregistryCB.setSelected(bbb(s));
            s = W.getDataDOM(e, "serverName");
            serverNameTF.setText(s);
            ee = W.getChildByTagNameDOM(e, "clients");
            Element eee = null;
            ArrayList<String> tmpAl = new ArrayList<String>();
            String defaultClient = null;
            ArrayList al = W.getChildrenByTagNameDOM(ee, "client");
            Iterator i = al.iterator();
            while (i.hasNext()) {
                eee = (Element) i.next();
                String clientString = W.getDataDOM(eee);
                tmpAl.add(clientString);
                String defaultString = W.getAttrDataDOM(eee, "default");
                if (defaultString.equals("true")) {
                    defaultClient = clientString;
                }
            }
            String ss[] = (String[]) tmpAl.toArray(new String[0]);
            clientClassCB.removeAllItems();
            for (int ii = 0; ii < ss.length; ii++) clientClassCB.addItem(ss[ii]);
            clientClassCB.setSelectedItem(defaultClient);
            ee = W.getChildByTagNameDOM(e, "loadVE");
            s = W.getAttrDataDOM(ee, "enable");
            emptyCB.setSelected(bbb(s) == false);
            s = W.getAttrDataDOM(ee, "file");
            roomFileTF.setText(s);
            ee = W.getChildByTagNameDOM(e, "elmBridge");
            s = W.getAttrDataDOM(ee, "enable");
            bridgeCB.setSelected(bbb(s));
            s = W.getAttrDataDOM(ee, "confFile");
            bridgeConfFileTF.setText(s);
            ee = W.getChildByTagNameDOM(e, "outIPAddress");
            s = W.getDataDOM(ee);
            bridgeOutIPTF.setText(s);
            bridgeInIPTF.setText(W.getIPAddress());
        } catch (Exception ee) {
            makeDefaultConfiguration();
            saveConfiguration();
            System.out.println("A default config file was created.");
        }
        packAndShow();
    }
protected void setOuterIP() {
        try {
            URL url = new URL("http://elm-ve.sf.net/ipCheck/ipCheck.cgi");
            InputStreamReader isr = new InputStreamReader(url.openStream());
            BufferedReader br = new BufferedReader(isr);
            String ip = br.readLine();
            ip = ip.trim();
            bridgeOutIPTF.setText(ip);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
public String getHtmlCode(String urlString) {
        StringBuffer result = new StringBuffer();
        BufferedReader in = null;
        try {
            URL url = new URL((urlString));
            URLConnection con = url.openConnection();
            in = new BufferedReader(new InputStreamReader(con.getInputStream(), "ISO-8859-1"));
            String line = null;
            while ((line = in.readLine()) != null) {
                result.append(line + "\r\n");
            }
            in.close();
        } catch (MalformedURLException e) {
            System.out.println("Unable to connect to URL: " + urlString);
        } catch (IOException e) {
            System.out.println("IOException when connecting to URL: " + urlString);
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception ex) {
                    System.out.println("Exception throws at finally close reader when connecting to URL: " + urlString);
                }
            }
        }
        return result.toString();
    }
public String getHtmlCodeUnCharset(String urlString) {
        StringBuffer result = new StringBuffer();
        BufferedReader in = null;
        try {
            URL url = new URL((urlString));
            URLConnection con = url.openConnection();
            in = new BufferedReader(new InputStreamReader(con.getInputStream()));
            String line = null;
            while ((line = in.readLine()) != null) {
                result.append(line + "\r\n");
            }
            in.close();
        } catch (MalformedURLException e) {
            System.out.println("Unable to connect to URL: " + urlString);
        } catch (IOException e) {
            System.out.println("IOException when connecting to URL: " + urlString);
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (Exception ex) {
                    System.out.println("Exception throws at finally close reader when connecting to URL: " + urlString);
                }
            }
        }
        return result.toString();
    }
public static void main(String[] args) throws IOException {
        System.out.println("start");
        URL url = new URL("https://spreadsheets.google.com/feeds/list/" + "0AnoMCh3_x82sdERLR3FvVDBIWXpjT1JlcENmOFdERVE/" + "od7/public/basic");
        InputStream is = url.openStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        String line;
        while ((line = br.readLine()) != null) {
            String[] mass = line.split("<entry>");
            for (String m : mass) {
                System.out.println(m);
            }
        }
    }