semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public void sendMessage(String messageBufferName, String messageStr, String timeout) throws AppFabricException {
        MessageBufferUtil msgBufferUtilObj = new MessageBufferUtil(solutionName, TokenConstants.getSimpleAuthAuthenticationType());
        String requestUri = msgBufferUtilObj.getRequestUri();
        String sendPath = MessageBufferConstants.getPATH_FOR_SEND_MESSAGE();
        String timeOutParameter = MessageBufferConstants.getTIMEOUTPARAMETER();
        String messageBufferUri = msgBufferUtilObj.getMessageUri(messageBufferName, sendPath);
        String message = msgBufferUtilObj.getFormattedMessage(messageStr);
        String authorizationToken = "";
        try {
            ACSTokenProvider tp = new ACSTokenProvider(httpWebProxyServer_, httpWebProxyPort_, this.credentials);
            authorizationToken = tp.getACSToken(requestUri, messageBufferUri);
            messageBufferUri = messageBufferUri.replaceAll("http", "https");
            String sendUri = messageBufferUri + "?" + timeOutParameter + "=" + timeout;
            URL urlConn = new URL(sendUri);
            HttpURLConnection connection;
            if (httpWebProxy_ != null) connection = (HttpURLConnection) urlConn.openConnection(httpWebProxy_); else connection = (HttpURLConnection) urlConn.openConnection();
            connection.setRequestMethod("POST");
            connection.setRequestProperty("Content-type", MessageBufferConstants.getCONTENT_TYPE_PROPERTY_FOR_TEXT());
            connection.setRequestProperty("Content-Length", "" + message.length());
            connection.setRequestProperty("Expect", "100-continue");
            connection.setRequestProperty("Accept", "*/*");
            String authStr = TokenConstants.getWrapAuthenticationType() + " " + TokenConstants.getWrapAuthorizationHeaderKey() + "=\"" + authorizationToken + "\"";
            connection.setRequestProperty("Authorization", authStr);
            connection.setUseCaches(false);
            connection.setDoInput(true);
            connection.setDoOutput(true);
            DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
            wr.writeBytes(message);
            wr.flush();
            wr.close();
            if (LoggerUtil.getIsLoggingOn()) SDKLoggerHelper.logRequest(connection, SDKLoggerHelper.RecordType.SendMessage_REQUEST);
            String responseCode = "<responseCode>" + connection.getResponseCode() + "</responseCode>";
            if (!((connection.getResponseCode() == MessageBufferConstants.HTTP_STATUS_CODE_ACCEPTED) || (connection.getResponseCode() == MessageBufferConstants.HTTP_STATUS_CODE_CREATED) || (connection.getResponseCode() == MessageBufferConstants.HTTP_STATUS_CODE_OK))) {
                throw new AppFabricException("Message could not be sent. Error.Response code: " + connection.getResponseCode());
            }
            if (LoggerUtil.getIsLoggingOn()) SDKLoggerHelper.logMessage(URLEncoder.encode(responseCode, "UTF-8"), SDKLoggerHelper.RecordType.SendMessage_RESPONSE);
        } catch (Exception e) {
            throw new AppFabricException(e.getMessage());
        }
    }
public Updater() {
        try {
            setTitle("OssoBook Updater");
            System.setProperty("java.net.preferIPv4Stack", "true");
            initComponents();
            Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
            int posX = (screen.width / 2) - (640 / 2);
            int posY = (screen.height / 2) - (480 / 2);
            setLocation(posX, posY);
            jProgressBar1.setVisible(true);
            labelPercuentalProgress.setVisible(true);
            URL url = new URL(updatePath + "currentVersion.txt");
            URLConnection con = url.openConnection();
            con.connect();
            BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
            String line;
            for (; (line = in.readLine()) != null; ) {
                numberFiles++;
            }
            labelFileProgress.setText("0/" + numberFiles);
            labelPercuentalProgress.setText("0%");
            jProgressBar2.setMaximum(numberFiles);
            URL url2 = new URL(updatePath + "Changelog.txt");
            URLConnection con2 = url2.openConnection();
            con2.connect();
            BufferedReader in2 = new BufferedReader(new InputStreamReader(con2.getInputStream()));
            jTextArea1.setMargin(new Insets(10, 10, 10, 10));
            Font f = new Font("Monospaced", Font.PLAIN, 12);
            jTextArea1.setFont(f);
            for (; (line = in2.readLine()) != null; ) {
                jTextArea1.setText(jTextArea1.getText() + line + "\n");
            }
        } catch (IOException ex) {
            Logger.getLogger(Updater.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
public static String encodePassword(String plainTextPassword) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        StringBuffer sb = new StringBuffer();
        MessageDigest messageDigest = MessageDigest.getInstance("SHA-512");
        messageDigest.update(plainTextPassword.getBytes("UTF-8"));
        byte[] digestBytes = messageDigest.digest();
        String hex = null;
        for (int i = 0; i < digestBytes.length; i++) {
            hex = Integer.toHexString(0xFF & digestBytes[i]);
            if (hex.length() < 2) sb.append("0");
            sb.append(hex);
        }
        return new String(sb);
    }
public static void main(String[] args) {
        try {
            String default_uri = "http://www.cs.nmsu.edu/~bchisham/cgi-bin/phylows/tree/Tree3099?format=graphml";
            URL gurl = new URL(default_uri);
            InputStream is = gurl.openStream();
            Scanner iscan = new Scanner(is);
            while (iscan.hasNext()) {
                System.out.println(iscan.next());
            }
        } catch (MalformedURLException ex) {
            Logger.getLogger(GraphUrlLoader.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
        }
    }
@Override
    public ImageData getImageData(URL url) {
        InputStream in = null;
        try {
            URLConnection conn = url.openConnection();
            conn.setRequestProperty("user-agent", "Tahiti/Alpha5x");
            conn.setRequestProperty("agent-system", "aglets");
            conn.setAllowUserInteraction(true);
            conn.connect();
            in = conn.getInputStream();
            String type = conn.getContentType();
            int len = conn.getContentLength();
            if (len < 0) {
                len = in.available();
            }
            byte[] b = new byte[len];
            int off = 0;
            int n = 0;
            while (n < len) {
                int count = in.read(b, off + n, len - n);
                if (count < 0) {
                    throw new java.io.EOFException();
                }
                n += count;
            }
            in.close();
            return new AgletImageData(url, b, type);
        } catch (Exception ex) {
            ex.printStackTrace();
            return null;
        }
    }
public Music(URL url, boolean streamingHint) throws SlickException {
        SoundStore.get().init();
        String ref = url.getFile();
        try {
            if (ref.toLowerCase().endsWith(".ogg")) {
                if (streamingHint) {
                    sound = SoundStore.get().getOggStream(url);
                } else {
                    sound = SoundStore.get().getOgg(url.openStream());
                }
            } else if (ref.toLowerCase().endsWith(".wav")) {
                sound = SoundStore.get().getWAV(url.openStream());
            } else if (ref.toLowerCase().endsWith(".xm") || ref.toLowerCase().endsWith(".mod")) {
                sound = SoundStore.get().getMOD(url.openStream());
            } else if (ref.toLowerCase().endsWith(".aif") || ref.toLowerCase().endsWith(".aiff")) {
                sound = SoundStore.get().getAIF(url.openStream());
            } else {
                throw new SlickException("Only .xm, .mod, .ogg, and .aif/f are currently supported.");
            }
        } catch (Exception e) {
            Log.error(e);
            throw new SlickException("Failed to load sound: " + url);
        }
    }
private static String encode(final String input) throws UnsupportedEncodingException, NoSuchAlgorithmException {
        MessageDigest md = MessageDigest.getInstance("MD5");
        md.reset();
        md.update(input.getBytes("UTF-8"));
        return toHexString(md.digest());
    }
public static void call(String host, String port, String method, String[] params) {
        cat.debug("call (host:" + host + " port:" + port + " method:" + method);
        try {
            String message = null;
            StringBuffer bufMessage = new StringBuffer();
            bufMessage.append("<?xml version='1.0' encoding='ISO-8859-1'?>");
            bufMessage.append("<methodCall>");
            bufMessage.append("<methodName>");
            bufMessage.append(method);
            bufMessage.append("</methodName>");
            bufMessage.append("<params>");
            if (params != null && params.length > 0) {
                for (int i = 0; i < params.length; i++) {
                    bufMessage.append("<param><value><![CDATA[" + params[i] + "]]></value></param>");
                }
            }
            bufMessage.append("</params></methodCall>");
            message = bufMessage.toString();
            bufMessage = null;
            String stringUrl = "http://" + host + ":" + port + "/RPC2";
            cat.debug("Sending message to: " + stringUrl + "\n" + message);
            URL url = new URL(stringUrl);
            URLConnection urlConnection = url.openConnection();
            urlConnection.setDoOutput(true);
            urlConnection.getOutputStream().write(message.getBytes());
            urlConnection.getOutputStream().flush();
            urlConnection.getOutputStream().close();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
            String line;
            while ((line = bufferedReader.readLine()) != null) {
                cat.debug("#server# " + line);
            }
            bufferedReader.close();
        } catch (Exception e) {
            cat.debug("Unable to send link to Gnowsis!", e);
        }
    }
static Collection<InetSocketAddress> getAddresses(Context ctx, long userId) throws Exception {
        AGLog.d(TAG, "Connecting to HTTP service to obtain IP addresses");
        String host = (String) ctx.getResources().getText(R.string.gg_webservice_addr);
        String ver = App.getInstance().getGGClientVersion();
        String url = host + "?fmnumber=" + Long.toString(userId) + "&lastmsg=0&version=" + ver;
        HttpClient httpClient = new DefaultHttpClient();
        AGLog.d(TAG, "connecting to http service at " + url);
        HttpGet request = new HttpGet(url);
        HttpResponse response = httpClient.execute(request);
        AGLog.d(TAG, "response status:" + response.getStatusLine().getReasonPhrase());
        HttpEntity ent = response.getEntity();
        if (ent == null) {
            AGLog.e(TAG, "No response entity");
            throw new ClientProtocolException("No response entity");
        }
        InputStream content = ent.getContent();
        BufferedReader reader = new BufferedReader(new InputStreamReader(content));
        String line = reader.readLine();
        AGLog.d(TAG, "response: " + line);
        StringTokenizer tokenizer = new StringTokenizer(line, " ");
        @SuppressWarnings("unused") String status = tokenizer.nextToken();
        @SuppressWarnings("unused") String unknown = tokenizer.nextToken();
        ArrayList<InetSocketAddress> result = new ArrayList<InetSocketAddress>();
        while (tokenizer.hasMoreTokens()) {
            StringTokenizer addrport = new StringTokenizer(tokenizer.nextToken(), ":");
            String addrStr = addrport.nextToken();
            if (InetAddressUtils.isIPv4Address(addrStr)) {
                AGLog.d(TAG, "Address decoded successfully: " + addrStr);
            } else {
                AGLog.w(TAG, "Failed to decode address: " + addrStr);
                continue;
            }
            String portStr;
            if (addrport.hasMoreTokens()) {
                portStr = addrport.nextToken();
            } else {
                portStr = (String) ctx.getResources().getText(R.string.gg_default_port);
            }
            AGLog.d(TAG, "Port decoded successfully: " + portStr);
            short port = Short.decode(portStr);
            result.add(new InetSocketAddress(addrStr, port));
        }
        return result;
    }
public void execUpdate(String sqlStmts[]) throws SQLException {
        if (conn == null || conn.isClosed()) throw new SQLException("The connection has not been established yet.");
        if (sqlStmts == null || sqlStmts.length == 0) throw new SQLException("SQL-statement is null.");
        conn.setAutoCommit(false);
        try {
            for (int i = 0; i < sqlStmts.length; i++) {
                stmt = conn.createStatement();
                stmt.executeUpdate(sqlStmts[i]);
                logger.debug(sqlStmts[i]);
                stmt.close();
            }
            conn.commit();
        } catch (SQLException ex) {
            conn.rollback();
            throw ex;
        }
    }
public void compareResult(String path, String expected) throws IOException {
        if (path.length() == 0 || path.charAt(0) != '/') path = "/" + path;
        URL url = new URL(getBase() + path);
        String actual = IOUtils.toString(url.openStream());
        Assert.assertEquals(url.toString(), expected, actual);
    }
public static InputStream openRemoteFile(URL urlParam) throws KExceptionClass {
        InputStream result = null;
        try {
            result = urlParam.openStream();
        } catch (IOException error) {
            String message = new String();
            message = "No se puede abrir el recurso [";
            message += urlParam.toString();
            message += "][";
            message += error.toString();
            message += "]";
            throw new KExceptionClass(message, error);
        }
        ;
        return (result);
    }
private void parseXmlFile() throws IOException {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        try {
            DocumentBuilder db = dbf.newDocumentBuilder();
            if (file != null) {
                dom = db.parse(file);
            } else {
                dom = db.parse(url.openStream());
            }
        } catch (ParserConfigurationException pce) {
            pce.printStackTrace();
        } catch (SAXException se) {
            se.printStackTrace();
        }
    }
protected static InputStream loadResource(String resource) throws MissingResourceException {
        Thread thread = Thread.currentThread();
        ClassLoader cLoader = thread.getContextClassLoader();
        URL url = cLoader.getResource(resource);
        if (url == null) {
            throw new MissingResourceException("Unable to find resource '" + resource + "'.", resource, resource);
        }
        try {
            InputStream is = url.openStream();
            return is;
        } catch (IOException e) {
            throw new MissingResourceException("Unable to load resource '" + resource + "' (IOException).", resource, resource);
        }
    }
public static String hashString(String sPassword) {
        if (sPassword == null || sPassword.equals("")) {
            return "empty:";
        } else {
            try {
                MessageDigest md = MessageDigest.getInstance("SHA-1");
                md.update(sPassword.getBytes("UTF-8"));
                byte[] res = md.digest();
                return "sha1:" + byte2hex(res);
            } catch (NoSuchAlgorithmException e) {
                return "plain:" + sPassword;
            } catch (UnsupportedEncodingException e) {
                return "plain:" + sPassword;
            }
        }
    }
static Matrix readMatrix(String filename, int nrow, int ncol) {
        Matrix cij = new Matrix(nrow, ncol);
        try {
            URL url = filename.getClass().getResource(filename);
            LineNumberReader lnr = new LineNumberReader(new InputStreamReader(url.openStream()));
            for (int i = 0; i < nrow; i++) for (int j = 0; j < ncol; j++) cij.set(i, j, Double.parseDouble(lnr.readLine()));
        } catch (Exception xc) {
            xc.printStackTrace();
        }
        return cij;
    }
static HashSet<Integer> readZoneIDs(String zoneFileName) {
        HashSet<Integer> zoneids = new HashSet<Integer>();
        try {
            URL url = zoneFileName.getClass().getResource(zoneFileName);
            LineNumberReader lnr = new LineNumberReader(new InputStreamReader(url.openStream()));
            String line = null;
            while ((line = lnr.readLine()) != null) zoneids.add(Integer.parseInt(line));
        } catch (Exception xc) {
            xc.printStackTrace();
        }
        return zoneids;
    }
static Matrix readMatrix1(String filename, int nrow, int ncol) {
        String inputString = null, value = null;
        int col = 0;
        double b = 0;
        Matrix cij = new Matrix(nrow, ncol);
        try {
            URL url = filename.getClass().getResource(filename);
            LineNumberReader lnr = new LineNumberReader(new InputStreamReader(url.openStream()));
            for (int i = 0; i < nrow; i++) for (int j = 0; j < ncol; j++) {
                inputString = lnr.readLine();
                int found = -2;
                while (found != -1) {
                    found = inputString.indexOf(";");
                    if (found != -1) {
                        value = inputString.substring(0, found);
                        inputString = inputString.substring(found + 1);
                    } else {
                        value = inputString;
                    }
                    col = col + 1;
                    if (col == 3) {
                        if (value != null) cij.set(i, j, Double.parseDouble(value)); else cij.set(i, j, 0);
                    }
                }
                col = 0;
            }
        } catch (Exception xc) {
            xc.printStackTrace();
        }
        return cij;
    }
@Test
    public void returnsEnclosedResponseOnUnsuccessfulException() throws Exception {
        Exception e = new UnsuccessfulResponseException(resp);
        expect(mockBackend.execute(host, req, ctx)).andThrow(e);
        replay(mockBackend);
        HttpResponse result = impl.execute(host, req, ctx);
        verify(mockBackend);
        assertSame(resp, result);
    }
protected void copyFile(File from, File to) throws IOException {
        new File(intSfPath).delete();
        if (to.exists() && (from.length() == to.length()) && (from.lastModified() == to.lastModified())) return;
        if (to.exists()) to.delete();
        to.createNewFile();
        FileChannel inFC = null;
        FileChannel outFC = null;
        try {
            inFC = new FileInputStream(from).getChannel();
            outFC = new FileOutputStream(to).getChannel();
            long cnt = outFC.transferFrom(inFC, 0, inFC.size());
            if (cnt < inFC.size()) throw new IOException("File copy failed");
        } finally {
            if (inFC != null) {
                try {
                    inFC.close();
                } catch (IOException ex) {
                }
            }
            if (outFC != null) {
                try {
                    outFC.close();
                } catch (IOException ex) {
                }
            }
            to.setLastModified(from.lastModified());
        }
    }
private void copyFile(File source, File destination) throws IOException {
        FileInputStream fileInputStream = null;
        FileOutputStream fileOutputStream = null;
        try {
            fileInputStream = new FileInputStream(source);
            fileOutputStream = new FileOutputStream(destination);
            int bufferLength = 1024;
            byte[] buffer = new byte[bufferLength];
            int readCount = 0;
            while ((readCount = fileInputStream.read(buffer)) != -1) {
                fileOutputStream.write(buffer, 0, readCount);
            }
        } finally {
            if (fileInputStream != null) {
                fileInputStream.close();
            }
            if (fileOutputStream != null) {
                fileOutputStream.close();
            }
        }
    }
public static String encrypt32(String plainText) {
        String str = "";
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(plainText.getBytes());
            byte b[] = md.digest();
            int i;
            StringBuffer buf = new StringBuffer("");
            for (int offset = 0; offset < b.length; offset++) {
                i = b[offset];
                if (i < 0) i += 256;
                if (i < 16) buf.append("0");
                buf.append(Integer.toHexString(i));
            }
            str = buf.toString();
            System.out.println("result: " + buf.toString());
            System.out.println("result: " + buf.toString().substring(8, 24));
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
            return str;
        }
        return str;
    }
public void addEntry(InputStream jis, JarEntry entry) throws IOException, URISyntaxException {
        File target = new File(this.target.getPath() + entry.getName()).getAbsoluteFile();
        if (!target.exists()) {
            target.createNewFile();
        }
        if ((new File(this.source.toURI())).isDirectory()) {
            File sourceEntry = new File(this.source.getPath() + entry.getName());
            FileInputStream fis = new FileInputStream(sourceEntry);
            byte[] classBytes = new byte[fis.available()];
            fis.read(classBytes);
            (new FileOutputStream(target)).write(classBytes);
        } else {
            readwriteStreams(jis, (new FileOutputStream(target)));
        }
    }
public void setUrl(URL url) throws PDFException, PDFSecurityException, IOException {
        InputStream in = null;
        try {
            URLConnection urlConnection = url.openConnection();
            in = urlConnection.getInputStream();
            String pathOrURL = url.toString();
            setInputStream(in, pathOrURL);
        } finally {
            if (in != null) {
                in.close();
            }
        }
    }
public static boolean doPost(String urlString, Map<String, String> nameValuePairs) throws IOException {
        URL url = new URL(urlString);
        URLConnection conn = url.openConnection();
        conn.setDoOutput(true);
        PrintWriter out = new PrintWriter(conn.getOutputStream());
        boolean first = true;
        for (Map.Entry<String, String> pair : nameValuePairs.entrySet()) {
            if (first) first = false; else out.print('&');
            String name = pair.getKey();
            String value = pair.getValue();
            out.print(name);
            out.print('=');
            out.print(URLEncoder.encode(value, "UTF-8"));
        }
        out.close();
        Scanner in;
        StringBuilder response = new StringBuilder();
        try {
            in = new Scanner(conn.getInputStream());
        } catch (IOException ex) {
            if (!(conn instanceof HttpURLConnection)) throw ex;
            InputStream err = ((HttpURLConnection) conn).getErrorStream();
            in = new Scanner(err);
        }
        while (in.hasNextLine()) {
            response.append(in.nextLine());
            response.append("\n");
        }
        in.close();
        return true;
    }