semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
private Properties loadDefaultProperties() throws IOException {
        Properties merged = new Properties();
        try {
            merged.setProperty("user", System.getProperty("user.name"));
        } catch (java.lang.SecurityException se) {
        }
        ClassLoader cl = getClass().getClassLoader();
        if (cl == null) cl = ClassLoader.getSystemClassLoader();
        if (cl == null) {
            logger.debug("Can't find a classloader for the Driver; not loading driver configuration");
            return merged;
        }
        logger.debug("Loading driver configuration via classloader " + cl);
        ArrayList urls = new ArrayList();
        Enumeration urlEnum = cl.getResources("org/postgresql/driverconfig.properties");
        while (urlEnum.hasMoreElements()) {
            urls.add(urlEnum.nextElement());
        }
        for (int i = urls.size() - 1; i >= 0; i--) {
            URL url = (URL) urls.get(i);
            logger.debug("Loading driver configuration from: " + url);
            InputStream is = url.openStream();
            merged.load(is);
            is.close();
        }
        return merged;
    }
private void copyFile(File source, File dest) throws IOException {
        FileChannel sourceChannel = new FileInputStream(source).getChannel();
        FileChannel destinationChannel = new FileOutputStream(dest).getChannel();
        sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
        sourceChannel.close();
        destinationChannel.close();
    }
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.listview);
        HttpGet request = new HttpGet(SERVICE_URI + "/json/getroutes/1");
        request.setHeader("Accept", "application/json");
        request.setHeader("Content-type", "application/json");
        DefaultHttpClient httpClient = new DefaultHttpClient();
        String theString = new String("");
        try {
            HttpResponse response = httpClient.execute(request);
            HttpEntity responseEntity = response.getEntity();
            InputStream stream = responseEntity.getContent();
            BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
            Vector<String> vectorOfStrings = new Vector<String>();
            String tempString = new String();
            String tempStringAgent = new String();
            String tempStringClient = new String();
            String tempStringRoute = new String();
            String tempStringZone = new String();
            StringBuilder builder = new StringBuilder();
            String line;
            while ((line = reader.readLine()) != null) {
                builder.append(line);
            }
            stream.close();
            theString = builder.toString();
            JSONObject json = new JSONObject(theString);
            Log.i("_GetClient_", "<jsonobject>\n" + json.toString() + "\n</jsonobject>");
            this.dm = new DataManipulator(this);
            JSONArray nameArray = json.getJSONArray("GetRoutesByAgentResult");
            for (int i = 0; i < nameArray.length(); i++) {
                tempStringAgent = nameArray.getJSONObject(i).getString("Agent");
                tempStringClient = nameArray.getJSONObject(i).getString("Client");
                tempStringRoute = nameArray.getJSONObject(i).getString("Route");
                tempStringZone = nameArray.getJSONObject(i).getString("Zone");
                Log.i("_GetClient_", "<Agent" + i + ">" + tempStringAgent + "</Agent" + i + ">\n");
                Log.i("_GetClient_", "<Client" + i + ">" + tempStringClient + "</Client" + i + ">\n");
                Log.i("_GetClient_", "<Route" + i + ">" + tempStringRoute + "</Route" + i + ">\n");
                Log.i("_GetClient_", "<Zone" + i + ">" + tempStringZone + "</Zone" + i + ">\n");
                tempString = nameArray.getJSONObject(i).getString("Client") + "\n" + nameArray.getJSONObject(i).getString("Route") + "\n" + nameArray.getJSONObject(i).getString("Zone");
                vectorOfStrings.add(new String(tempString));
            }
            int orderCount = vectorOfStrings.size();
            String[] orderTimeStamps = new String[orderCount];
            vectorOfStrings.copyInto(orderTimeStamps);
            setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, orderTimeStamps));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
@Override
    public void parse() throws DocumentException, IOException {
        URL url = new URL(getDataUrl());
        URLConnection con = url.openConnection();
        BufferedReader bStream = new BufferedReader(new InputStreamReader(con.getInputStream()));
        String s = bStream.readLine();
        bStream.readLine();
        while ((s = bStream.readLine()) != null) {
            String[] tokens = s.split("\\|");
            ResultUnit unit = new ResultUnit(tokens[3], Float.valueOf(tokens[4]), Integer.valueOf(tokens[2]));
            set.add(unit);
        }
    }
private void copyLocalFile(File sourceFile, File destFile) throws IOException {
        if (!destFile.exists()) {
            destFile.createNewFile();
        }
        FileChannel source = null;
        FileChannel destination = null;
        try {
            source = new FileInputStream(sourceFile).getChannel();
            destination = new FileOutputStream(destFile).getChannel();
            destination.transferFrom(source, 0, source.size());
        } finally {
            if (source != null) {
                source.close();
            }
            if (destination != null) {
                destination.close();
            }
        }
    }
public static String getStringFromInputStream(InputStream in) throws Exception {
        CachedOutputStream bos = new CachedOutputStream();
        IOUtils.copy(in, bos);
        in.close();
        bos.close();
        return bos.getOut().toString();
    }
protected boolean checkLink(URL url) {
        try {
            URLConnection connection = url.openConnection();
            connection.connect();
            return true;
        } catch (IOException e) {
            MsgLog.error("DapParser.checkLink(): IOException: " + e.toString());
            return false;
        }
    }
public static void copyAssetFile(Context ctx, String srcFileName, String targetFilePath) {
        AssetManager assetManager = ctx.getAssets();
        try {
            InputStream is = assetManager.open(srcFileName);
            File out = new File(targetFilePath);
            if (!out.exists()) {
                out.getParentFile().mkdirs();
                out.createNewFile();
            }
            OutputStream os = new FileOutputStream(out);
            IOUtils.copy(is, os);
            is.close();
            os.close();
        } catch (IOException e) {
            AIOUtils.log("error when copyAssetFile", e);
        }
    }
public static File writeInternalFile(Context cx, URL url, String dir, String filename) {
        FileOutputStream fos = null;
        File fi = null;
        try {
            fi = newInternalFile(cx, dir, filename);
            fos = FileUtils.openOutputStream(fi);
            int length = IOUtils.copy(url.openStream(), fos);
            log(length + " bytes copyed.");
        } catch (IOException e) {
            AIOUtils.log("", e);
        } finally {
            try {
                fos.close();
            } catch (IOException e) {
                AIOUtils.log("", e);
            }
        }
        return fi;
    }
public String get(String s, String encoding) throws Exception {
        if (!s.startsWith("http")) return "";
        StringBuilder sb = new StringBuilder();
        try {
            String result = null;
            URL url = new URL(s);
            URLConnection connection = url.openConnection();
            connection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
            connection.setDoOutput(false);
            if (encoding == null) encoding = "UTF-8";
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream(), encoding));
            String inputLine;
            String contentType = connection.getContentType();
            if (contentType.startsWith("text") || contentType.startsWith("application/xml")) {
                while ((inputLine = in.readLine()) != null) {
                    sb.append(inputLine);
                    sb.append("\n");
                }
            }
            in.close();
        } catch (Exception e) {
            e.printStackTrace();
            throw e;
        }
        return sb.toString();
    }
public Resource readResource(URL url, ResourceManager resourceManager) throws NAFException {
        XMLResource resource = new XMLResource(resourceManager, url);
        InputStream in = null;
        try {
            in = url.openStream();
            ArrayList<Transformer> trList = null;
            Document doc = docbuilder.parse(in);
            for (Node n = doc.getFirstChild(); n != null; n = n.getNextSibling()) {
                if (n.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE && "xml-stylesheet".equals(n.getNodeName())) {
                    ProcessingInstruction pi = (ProcessingInstruction) n;
                    Map<String, String> attrs = DOMUtil.parseProcessingInstructionAttributes(pi);
                    if ("text/xsl".equals(attrs.get("type"))) {
                        String href = attrs.get("href");
                        if (href == null) throw new NAFException("Style sheet processing instructions must have an \"href\" attribute");
                        try {
                            Transformer t = styleManager.createTransformer(new URL(url, href));
                            if (trList == null) trList = new ArrayList<Transformer>();
                            trList.add(t);
                        } catch (Exception ex) {
                            throw new NAFException("Error reading style sheet resource \"" + href + "\"");
                        }
                    }
                }
            }
            if (trList != null) {
                for (Transformer t : trList) {
                    doc = (Document) styleManager.transform(t, doc);
                    if (LOGGER_DUMP.isDebugEnabled()) {
                        StringWriter swr = new StringWriter();
                        DOMUtil.dumpNode(doc, swr);
                        LOGGER_DUMP.debug("Transformed instance:\n" + swr + "\n");
                    }
                }
            }
            Element rootE = doc.getDocumentElement();
            if (!NAF_NAMESPACE_URI.equals(rootE.getNamespaceURI())) throw new NAFException("Root element does not use the NAF namespace");
            Object comp = createComponent(rootE, resource, null);
            resource.setRootObject(comp);
            return resource;
        } catch (Exception ex) {
            throw new NAFException("Error reading NAF resource \"" + url.toExternalForm() + "\"", ex);
        } finally {
            if (in != null) try {
                in.close();
            } catch (Exception ignored) {
            }
        }
    }
public static void copyFile(String inFile, String outFile) {
        File in = new File(inFile);
        File out = new File(outFile);
        try {
            FileChannel inChannel = new FileInputStream(in).getChannel();
            FileChannel outChannel = new FileOutputStream(out).getChannel();
            try {
                inChannel.transferTo(0, inChannel.size(), outChannel);
            } finally {
                if (inChannel != null) inChannel.close();
                if (outChannel != null) outChannel.close();
            }
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
public void setImg() {
        JFileChooser jFileChooser1 = new JFileChooser();
        String separator = "";
        if (JFileChooser.APPROVE_OPTION == jFileChooser1.showOpenDialog(this.getFatherFrame())) {
            setPath(jFileChooser1.getSelectedFile().getPath());
            separator = jFileChooser1.getSelectedFile().separator;
            File dirImg = new File("." + separator + "images");
            if (!dirImg.exists()) {
                dirImg.mkdir();
            }
            int index = getPath().lastIndexOf(separator);
            String imgName = getPath().substring(index);
            String newPath = dirImg + imgName;
            try {
                File inputFile = new File(getPath());
                File outputFile = new File(newPath);
                if (!inputFile.getCanonicalPath().equals(outputFile.getCanonicalPath())) {
                    FileInputStream in = new FileInputStream(inputFile);
                    FileOutputStream out = new FileOutputStream(outputFile);
                    int c;
                    while ((c = in.read()) != -1) out.write(c);
                    in.close();
                    out.close();
                }
            } catch (Exception ex) {
                ex.printStackTrace();
                LogHandler.log(ex.getMessage(), Level.INFO, "LOG_MSG", isLoggingEnabled());
                JOptionPane.showMessageDialog(null, ex.getMessage().substring(0, Math.min(ex.getMessage().length(), getFatherPanel().MAX_DIALOG_MSG_SZ)) + "-" + getClass(), "Set image", JOptionPane.ERROR_MESSAGE);
            }
            setPath(newPath);
            bckImg = new ImageIcon(getPath());
        }
    }
public ActionResponse executeAction(ActionRequest request) throws Exception {
        BufferedReader in = null;
        try {
            CurrencyEntityManager em = new CurrencyEntityManager();
            String id = (String) request.getProperty("ID");
            CurrencyMonitor cm = getCurrencyMonitor(em, Long.valueOf(id));
            String code = cm.getCode();
            if (code == null || code.length() == 0) code = DEFAULT_SYMBOL;
            String tmp = URL.replace("@", code);
            ActionResponse resp = new ActionResponse();
            URL url = new URL(tmp);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            int status = conn.getResponseCode();
            if (status == 200) {
                in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                StringBuilder value = new StringBuilder();
                while (true) {
                    String line = in.readLine();
                    if (line == null) break;
                    value.append(line);
                }
                cm.setLastUpdateValue(new BigDecimal(value.toString()));
                cm.setLastUpdateTs(new Date());
                em.updateCurrencyMonitor(cm);
                resp.addResult("CURRENCYMONITOR", cm);
            } else {
                resp.setErrorCode(ActionResponse.GENERAL_ERROR);
                resp.setErrorMessage("HTTP Error [" + status + "]");
            }
            return resp;
        } catch (Exception e) {
            String st = MiscUtils.stackTrace2String(e);
            logger.error(st);
            throw e;
        } finally {
            if (in != null) {
                in.close();
            }
        }
    }
private static String digest(String buffer) {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(buffer.getBytes());
            return new String(encodeHex(md5.digest(key)));
        } catch (NoSuchAlgorithmException e) {
        }
        return null;
    }
public boolean validatePassword(UserType nameMatch, String password) {
        try {
            MessageDigest md = MessageDigest.getInstance(HASH_ALGORITHM);
            md.reset();
            md.update(nameMatch.getSalt().getBytes("UTF-8"));
            md.update(password.getBytes("UTF-8"));
            String encodedString = new String(Base64.encode(md.digest()));
            return encodedString.equals(nameMatch.getPassword());
        } catch (UnsupportedEncodingException ex) {
            logger.fatal("Your computer does not have UTF-8 support for Java installed.", ex);
            logger.fatal("Shutting down...");
            GlobalUITools.displayFatalExceptionMessage(null, "UTF-8 for Java not installed", ex, true);
            assert false : "This should never happen";
            return false;
        } catch (NoSuchAlgorithmException ex) {
            String errorMessage = "Could not use algorithm " + HASH_ALGORITHM;
            logger.fatal(ex.getMessage());
            logger.fatal(errorMessage);
            GlobalUITools.displayFatalExceptionMessage(null, "Could not use algorithm " + HASH_ALGORITHM, ex, true);
            assert false : "This could should never be reached";
            return false;
        }
    }
public void setPassword(UserType user, String clearPassword) {
        try {
            Random r = new Random();
            String newSalt = Long.toString(Math.abs(r.nextLong()));
            MessageDigest md = MessageDigest.getInstance(HASH_ALGORITHM);
            md.reset();
            md.update(newSalt.getBytes("UTF-8"));
            md.update(clearPassword.getBytes("UTF-8"));
            String encodedString = new String(Base64.encode(md.digest()));
            user.setPassword(encodedString);
            user.setSalt(newSalt);
            this.markModified(user);
        } catch (UnsupportedEncodingException ex) {
            logger.fatal("Your computer does not have UTF-8 support for Java installed.", ex);
            GlobalUITools.displayFatalExceptionMessage(null, "UTF-8 for Java not installed", ex, true);
        } catch (NoSuchAlgorithmException ex) {
            String errorMessage = "Could not use algorithm " + HASH_ALGORITHM;
            logger.fatal(errorMessage, ex);
            GlobalUITools.displayFatalExceptionMessage(null, errorMessage, ex, true);
        }
    }
public void testDatastreamWork3() throws FedoraConnectionException, DigitalObjectManager.DigitalObjectNotFoundException, StoreException, ParseException, IOException {
        String content = "ahsddksjgldskdlfnskl\nlskdfjlsjdf\n";
        String pid = fedoraConnector.newObject();
        assertTrue(fedoraConnector.exists(pid));
        assertTrue(fedoraConnector.isPlanetsObject(pid));
        assertTrue(fedoraConnector.isDataObject(pid));
        assertTrue(fedoraConnector.isWritable(pid));
        try {
            fedoraConnector.getDatastreamString(pid, "CONTENT");
            fail("Datastream should not be there");
        } catch (DigitalObjectManager.DigitalObjectNotFoundException e) {
        }
        fedoraConnector.modifyDatastream(pid, "CONTENT", content, null);
        URL url = fedoraConnector.getDatastreamURL(pid, "CONTENT");
        InputStream stream = url.openStream();
        String storedContent = convertStreamToString(stream);
        assertEquals(content, storedContent);
        fedoraConnector.purgeObject(pid);
    }
private static boolean copyFile(File in, File out) {
        boolean ok = true;
        InputStream is = null;
        OutputStream os = null;
        try {
            is = new FileInputStream(in);
            os = new FileOutputStream(out);
            byte[] buffer = new byte[0xFFFF];
            for (int len; (len = is.read(buffer)) != -1; ) os.write(buffer, 0, len);
        } catch (IOException e) {
            System.err.println(e);
            ok = false;
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                    System.err.println(e);
                }
            }
            if (os != null) {
                try {
                    os.close();
                } catch (IOException e) {
                    System.err.println(e);
                }
            }
        }
        return ok;
    }
private static final BufferedInputStream createInputStreamFromRemoteUrl(String uri, ClientConnectionManager connectionManager) {
        InputStream contentInput = null;
        if (connectionManager == null) {
            try {
                URL url = new URI(uri).toURL();
                URLConnection conn = url.openConnection();
                conn.connect();
                contentInput = conn.getInputStream();
            } catch (Exception e) {
                Log.w(TAG, "Request failed: " + uri);
                e.printStackTrace();
                return null;
            }
        } else {
            final DefaultHttpClient mHttpClient = new DefaultHttpClient(connectionManager, HTTP_PARAMS);
            HttpUriRequest request = new HttpGet(uri);
            HttpResponse httpResponse = null;
            try {
                httpResponse = mHttpClient.execute(request);
                HttpEntity entity = httpResponse.getEntity();
                if (entity != null) {
                    contentInput = entity.getContent();
                }
            } catch (Exception e) {
                Log.w(TAG, "Request failed: " + request.getURI());
                return null;
            }
        }
        if (contentInput != null) {
            return new BufferedInputStream(contentInput, 4096);
        } else {
            return null;
        }
    }
public static String getMD5Hash(String hashthis) throws NoSuchAlgorithmException {
        byte[] key = "PATIENTISAUTHENTICATION".getBytes();
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        md5.update(hashthis.getBytes());
        return new String(HashUtility.base64Encode(md5.digest(key)));
    }
private String encode(String str) {
        StringBuffer buf = new StringBuffer();
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(str.getBytes());
            byte bytes[] = md5.digest();
            for (int i = 0; i < bytes.length; i++) {
                String s = Integer.toHexString(bytes[i] & 0xff);
                if (s.length() == 1) {
                    buf.append("0");
                }
                buf.append(s);
            }
        } catch (Exception ex) {
        }
        return buf.toString();
    }
public static void main(String[] args) {
        int dizi[] = { 23, 78, 45, 8, 3, 32, 56, 39, 92, 28 };
        boolean test = false;
        int kars = 0;
        int tas = 0;
        while (true) {
            for (int j = 0; j < dizi.length - 1; j++) {
                kars++;
                if (dizi[j] > dizi[j + 1]) {
                    int temp = dizi[j];
                    dizi[j] = dizi[j + 1];
                    dizi[j + 1] = temp;
                    test = true;
                    tas++;
                }
            }
            if (!test) {
                break;
            } else {
                test = false;
            }
        }
        for (int i = 0; i < dizi.length; i++) {
            System.out.print(dizi[i] + " ");
        }
        for (int i = 0; i < 5; i++) {
            System.out.println("i" + i);
        }
    }