semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public static void copyFile(final File in, final File out) throws IOException {
        final FileChannel inChannel = new FileInputStream(in).getChannel();
        final FileChannel outChannel = new FileOutputStream(out).getChannel();
        try {
            inChannel.transferTo(0, inChannel.size(), outChannel);
        } catch (IOException e) {
            throw e;
        } finally {
            if (inChannel != null) {
                inChannel.close();
            }
            if (outChannel != null) {
                outChannel.close();
            }
        }
    }
private Response doLoad(URL url, URL referer, String postData) throws IOException {
        URLConnection connection = PROXY == null ? url.openConnection() : url.openConnection(PROXY);
        COOKIES.writeCookies(connection);
        connection.setRequestProperty("User-Agent", USER_AGENT);
        if (referer != null) {
            connection.setRequestProperty("Referer", referer.toString());
        }
        if (postData != null) {
            connection.setDoInput(true);
            connection.setDoOutput(true);
            connection.setUseCaches(false);
            connection.setRequestProperty("CONTENT_LENGTH", "" + postData.length());
            OutputStream os = connection.getOutputStream();
            OutputStreamWriter osw = new OutputStreamWriter(os);
            osw.write(postData);
            osw.flush();
            osw.close();
        }
        connection.connect();
        COOKIES.readCookies(connection);
        previouseUrl = url;
        return responceInstance(url, connection.getInputStream(), connection.getContentType());
    }
public void run() {
        try {
            File f = new File(repository + fileName);
            if (!f.exists()) {
                URL url = new URL(urlString);
                URLConnection urlConnection = url.openConnection();
                urlConnection.connect();
                InputStream dis = url.openStream();
                File dir = new File(repository);
                if (!dir.exists()) dir.mkdirs();
                f.createNewFile();
                FileOutputStream fos = new FileOutputStream(f);
                byte[] buffer = new byte[4096];
                int len = 0;
                while ((len = dis.read(buffer)) > -1) fos.write(buffer, 0, len);
                fos.close();
                dis.close();
            }
            fireFileDownloadedListener(fileName);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
static byte[] getPassword(final String name, final String password) {
        try {
            final MessageDigest messageDigest = MessageDigest.getInstance("SHA");
            messageDigest.update(name.getBytes());
            messageDigest.update(password.getBytes());
            return messageDigest.digest();
        } catch (final NoSuchAlgorithmException e) {
            throw new JobException(e);
        }
    }
private void loadOperatorsXML() {
        startwindow.setMessage("Loading Operators...");
        try {
            URL url = Application.class.getClassLoader().getResource(Resources.getString("OPERATORS_XML"));
            InputStream input = url.openStream();
            OperatorsReader.registerOperators(Resources.getString("OPERATORS_XML"), input);
        } catch (FileNotFoundException e) {
            Logger.logException("File '" + Resources.getString("OPERATORS_XML") + "' not found.", e);
        } catch (IOException error) {
            Logger.logException(error.getMessage(), error);
        }
    }
public static boolean copyFileCover(String srcFileName, String descFileName, boolean coverlay) {
        File srcFile = new File(srcFileName);
        if (!srcFile.exists()) {
            System.out.println("�����ļ�ʧ�ܣ�Դ�ļ�" + srcFileName + "������!");
            return false;
        } else if (!srcFile.isFile()) {
            System.out.println("�����ļ�ʧ�ܣ�" + srcFileName + "����һ���ļ�!");
            return false;
        }
        File descFile = new File(descFileName);
        if (descFile.exists()) {
            if (coverlay) {
                System.out.println("Ŀ���ļ��Ѵ��ڣ�׼��ɾ��!");
                if (!FileOperateUtils.delFile(descFileName)) {
                    System.out.println("ɾ��Ŀ���ļ�" + descFileName + "ʧ��!");
                    return false;
                }
            } else {
                System.out.println("�����ļ�ʧ�ܣ�Ŀ���ļ�" + descFileName + "�Ѵ���!");
                return false;
            }
        } else {
            if (!descFile.getParentFile().exists()) {
                System.out.println("Ŀ���ļ����ڵ�Ŀ¼�����ڣ�����Ŀ¼!");
                if (!descFile.getParentFile().mkdirs()) {
                    System.out.println("����Ŀ���ļ����ڵ�Ŀ¼ʧ��!");
                    return false;
                }
            }
        }
        int readByte = 0;
        InputStream ins = null;
        OutputStream outs = null;
        try {
            ins = new FileInputStream(srcFile);
            outs = new FileOutputStream(descFile);
            byte[] buf = new byte[1024];
            while ((readByte = ins.read(buf)) != -1) {
                outs.write(buf, 0, readByte);
            }
            System.out.println("���Ƶ����ļ�" + srcFileName + "��" + descFileName + "�ɹ�!");
            return true;
        } catch (Exception e) {
            System.out.println("�����ļ�ʧ�ܣ�" + e.getMessage());
            return false;
        } finally {
            if (outs != null) {
                try {
                    outs.close();
                } catch (IOException oute) {
                    oute.printStackTrace();
                }
            }
            if (ins != null) {
                try {
                    ins.close();
                } catch (IOException ine) {
                    ine.printStackTrace();
                }
            }
        }
    }
private byte[] rawHttpPost(URL serverTimeStamp, Hashtable reqProperties, byte[] postData) {
        logger.info("[rawHttpPost.in]:: " + Arrays.asList(new Object[] { serverTimeStamp, reqProperties, postData }));
        URLConnection urlConn;
        DataOutputStream printout;
        DataInputStream input;
        byte[] responseBody = null;
        try {
            urlConn = serverTimeStamp.openConnection();
            urlConn.setDoInput(true);
            urlConn.setDoOutput(true);
            urlConn.setUseCaches(false);
            Iterator iter = reqProperties.entrySet().iterator();
            while (iter.hasNext()) {
                Map.Entry entry = (Map.Entry) iter.next();
                urlConn.setRequestProperty((String) entry.getKey(), (String) entry.getValue());
            }
            logger.debug("POSTing to: " + serverTimeStamp + " ...");
            printout = new DataOutputStream(urlConn.getOutputStream());
            printout.write(postData);
            printout.flush();
            printout.close();
            input = new DataInputStream(urlConn.getInputStream());
            byte[] buffer = new byte[1024];
            int bytesRead = 0;
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            while ((bytesRead = input.read(buffer, 0, buffer.length)) >= 0) {
                baos.write(buffer, 0, bytesRead);
            }
            input.close();
            responseBody = baos.toByteArray();
        } catch (MalformedURLException me) {
            logger.warn("[rawHttpPost]:: ", me);
        } catch (IOException ioe) {
            logger.warn("[rawHttpPost]:: ", ioe);
        }
        return responseBody;
    }
public static void copyFile(File file, String pathExport) throws IOException {
        File out = new File(pathExport);
        FileChannel sourceChannel = new FileInputStream(file).getChannel();
        FileChannel destinationChannel = new FileOutputStream(out).getChannel();
        sourceChannel.transferTo(0, sourceChannel.size(), destinationChannel);
        sourceChannel.close();
        destinationChannel.close();
    }
private static void unzipEntry(ZipFile zipfile, ZipEntry entry, File outputDir) throws IOException {
        if (entry.isDirectory()) {
            createDir(new File(outputDir, entry.getName()));
            return;
        }
        File outputFile = new File(outputDir, entry.getName());
        if (!outputFile.getParentFile().exists()) {
            createDir(outputFile.getParentFile());
        }
        BufferedInputStream inputStream = new BufferedInputStream(zipfile.getInputStream(entry));
        BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));
        try {
            IOUtils.copy(inputStream, outputStream);
        } finally {
            outputStream.close();
            inputStream.close();
        }
    }
@Test
    public void test_validate_geo_getEvents() {
        try {
            SchemaFactory factory = SchemaFactory.newInstance("http://www.w3.org/2001/XMLSchema");
            File schemaLocation = new File("tes.xsd");
            Schema schema = factory.newSchema(schemaLocation);
            Validator validator = schema.newValidator();
            URL url = new URL("http://ws.audioscrobbler.com/2.0/?method=geo.getevents&location=madrid&api_key=b25b959554ed76058ac220b7b2e0a026");
            InputStream inputStream = url.openStream();
            Source source = new StreamSource(inputStream);
            validator.validate(source);
        } catch (IOException ex) {
            Logger.getLogger(GetEvents_Test.class.getName()).log(Level.SEVERE, null, ex);
            assertFalse("File not found", true);
        } catch (SAXException ex) {
            Logger.getLogger(GetEvents_Test.class.getName()).log(Level.SEVERE, null, ex);
            assertFalse("Schema did not validate", true);
        }
        assertTrue(true);
    }
private static String encryptMD5(String password, Long digestSeed) {
        try {
            MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.reset();
            digest.update(password.getBytes("UTF-8"));
            digest.update(digestSeed.toString().getBytes("UTF-8"));
            byte[] messageDigest = digest.digest();
            StringBuffer hexString = new StringBuffer();
            for (int i = 0; i < messageDigest.length; i++) {
                hexString.append(Integer.toHexString(0xff & messageDigest[i]));
            }
            return hexString.toString();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        } catch (NullPointerException e) {
            return new StringBuffer().toString();
        }
    }
private static String encrypt(String algorithm, String password, Long digestSeed) {
        try {
            MessageDigest digest = MessageDigest.getInstance(algorithm);
            digest.reset();
            digest.update(password.getBytes("UTF-8"));
            digest.update(digestSeed.toString().getBytes("UTF-8"));
            byte[] messageDigest = digest.digest();
            StringBuffer hexString = new StringBuffer();
            for (int i = 0; i < messageDigest.length; i++) {
                hexString.append(Integer.toHexString((0xf0 & messageDigest[i]) >> 4));
                hexString.append(Integer.toHexString(0x0f & messageDigest[i]));
            }
            return hexString.toString();
        } catch (NoSuchAlgorithmException e) {
            throw new RuntimeException(e);
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        } catch (NullPointerException e) {
            return new StringBuffer().toString();
        }
    }
public static String SHA1(String text) throws NoSuchAlgorithmException {
        MessageDigest md = MessageDigest.getInstance("SHA-1");
        md.update(text.getBytes());
        byte byteData[] = md.digest();
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < byteData.length; i++) {
            sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
        }
        StringBuffer hexString = new StringBuffer();
        for (int i = 0; i < byteData.length; i++) {
            String hex = Integer.toHexString(0xff & byteData[i]);
            if (hex.length() == 1) hexString.append('0');
            hexString.append(hex);
        }
        return hexString.toString();
    }
private static void copyObjects(File[] source, String target) {
        for (int i = 0; i < source.length; i++) {
            try {
                File inputFile = source[i];
                File outputFile = new File(target + source[i].getName());
                FileReader in = new FileReader(inputFile);
                FileWriter out = new FileWriter(outputFile);
                int c;
                while ((c = in.read()) != -1) out.write(c);
                in.close();
                out.close();
            } catch (Exception ex) {
                Logger.error(ex.getClass() + " " + ex.getMessage());
                for (int j = 0; j < ex.getStackTrace().length; j++) Logger.error("     " + ex.getStackTrace()[j].toString());
                ex.printStackTrace();
            }
        }
    }
protected String getPostRequestContent(String urlText, String... postParams) 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());
        for (String param : postParams) {
            ps.print(param);
        }
        ps.close();
        urlcon.connect();
        BufferedReader reader = new BufferedReader(new InputStreamReader(urlcon.getInputStream()));
        String line = reader.readLine();
        reader.close();
        urlcon.disconnect();
        return line;
    }
private URL resolveRedirects(URL url, int redirectCount) throws IOException {
        URLConnection uc = url.openConnection();
        if (uc instanceof HttpURLConnection) {
            HttpURLConnection huc = (HttpURLConnection) uc;
            huc.setInstanceFollowRedirects(false);
            huc.connect();
            int responseCode = huc.getResponseCode();
            String location = huc.getHeaderField("location");
            huc.disconnect();
            if ((responseCode == HttpURLConnection.HTTP_MOVED_TEMP) && (redirectCount < 5)) {
                try {
                    URL newUrl = new URL(location);
                    return resolveRedirects(newUrl, redirectCount + 1);
                } catch (MalformedURLException ex) {
                    return url;
                }
            } else return url;
        } else return url;
    }
public static String loadPage(URL url) throws IOException {
        Reader in = null;
        URLConnection uc;
        HttpURLConnection huc = null;
        try {
            uc = url.openConnection();
            if (uc instanceof HttpURLConnection) {
                huc = (HttpURLConnection) uc;
                huc.setInstanceFollowRedirects(false);
                huc.connect();
                in = new InputStreamReader(huc.getInputStream());
                StringBuilder sb = new StringBuilder();
                int c;
                while ((c = in.read()) != -1) sb.append((char) c);
                return sb.toString();
            } else return null;
        } finally {
            try {
                if (in != null) in.close();
                if (huc != null) huc.disconnect();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }
protected Collection<BibtexEntry> getBibtexEntries(String ticket, String citations) throws IOException {
        try {
            URL url = new URL(URL_BIBTEX);
            URLConnection conn = url.openConnection();
            conn.setRequestProperty("Cookie", ticket + "; " + citations);
            conn.connect();
            BibtexParser parser = new BibtexParser(new BufferedReader(new InputStreamReader(conn.getInputStream())));
            return parser.parse().getDatabase().getEntries();
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }
    }
protected String getCitations(String ticket, String query) throws IOException {
        String urlQuery;
        try {
            urlQuery = "http://www.jstor.org/search/BasicResults?hp=" + MAX_CITATIONS + "&si=1&gw=jtx&jtxsi=1&jcpsi=1&artsi=1&Query=" + URLEncoder.encode(query, "UTF-8") + "&wc=on&citationAction=saveAll";
        } catch (UnsupportedEncodingException e) {
            throw new RuntimeException(e);
        }
        URL url = new URL(urlQuery);
        URLConnection conn = url.openConnection();
        conn.setRequestProperty("Cookie", ticket);
        return getCookie(COOKIE_CITATIONS, conn);
    }
public static final Bitmap getBitmap(final String key, int size) {
        Bitmap bmp = null;
        byte[] line = new byte[1024];
        int byteSize = 0;
        String urlStr = URI_IMAGE + key;
        try {
            URL url = new URL(urlStr);
            HttpURLConnection con = (HttpURLConnection) url.openConnection();
            con.setRequestMethod("GET");
            con.connect();
            InputStream is = con.getInputStream();
            ByteArrayOutputStream out = new ByteArrayOutputStream();
            while ((byteSize = is.read(line)) > 0) {
                out.write(line, 0, byteSize);
            }
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.inSampleSize = size;
            byte[] byteArray = out.toByteArray();
            bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length, options);
            is.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return bmp;
    }
public Download doDownload(HttpHeader[] headers, URI target) throws HttpRequestException {
        HttpRequest<E> con = createConnection(HttpMethods.METHOD_GET, target);
        if (defaultHeaders != null) {
            putHeaders(con, defaultHeaders);
        }
        if (headers != null) {
            putHeaders(con, headers);
        }
        HttpResponse<?> res = execute(con);
        if (res.getResponseCode() == 200) {
            return new Download(res);
        } else {
            throw new HttpRequestException(res.getResponseCode(), res.getResponseMessage());
        }
    }
public HttpResponse<E> doRequest(HttpMethods method, HttpHeader[] headers, boolean auth, URI target, BlipMessagePart body) throws HttpRequestException {
        HttpRequest<E> con = createConnection(method, target);
        if (defaultHeaders != null) {
            putHeaders(con, defaultHeaders);
        }
        if (headers != null) {
            putHeaders(con, headers);
        }
        try {
            if (auth && authStrategy != null) {
                authStrategy.perform(con);
            }
            if (body != null) {
                bodyGenerator.writeBody(con, body);
            }
            HttpResponse<E> res = execute(con);
            return res;
        } catch (IOException e) {
            throw new HttpRequestException("Error executing request", e);
        }
    }
public static boolean exec_applet(String fname, VarContainer vc, ActionContainer ac, ThingTypeContainer ttc, Output OUT, InputStream IN, boolean AT, Statement state, String[] arggies) {
        if (!urlpath.endsWith("/")) {
            urlpath = urlpath + '/';
        }
        if (!urlpath.startsWith("http://")) {
            urlpath = "http://" + urlpath;
        }
        String url = urlpath;
        if (fname.startsWith("dusty_")) {
            url = url + "libraries/" + fname;
        } else {
            url = url + "users/" + fname;
        }
        StringBuffer src = new StringBuffer(2400);
        try {
            String s;
            BufferedReader br = new BufferedReader(new InputStreamReader(new URL(url).openStream()));
            while ((s = br.readLine()) != null) {
                src.append(s).append('\n');
            }
            br.close();
        } catch (Exception e) {
            OUT.println(new DSOut(DSOut.ERR_OUT, -1, "Dustyscript failed at reading the file'" + fname + "'\n\t...for 'use' statement"), vc, AT);
            return false;
        }
        fork(src, vc, ac, ttc, OUT, IN, AT, state, arggies);
        return true;
    }
public static boolean copyFile(File dest, File source) {
        FileInputStream fis = null;
        FileOutputStream fos = null;
        boolean rv = false;
        byte[] buf = new byte[1000000];
        int bytesRead = 0;
        if (!dest.getParentFile().exists()) dest.getParentFile().mkdirs();
        try {
            fis = new FileInputStream(source);
            fos = new FileOutputStream(dest);
            while ((bytesRead = fis.read(buf)) > 0) fos.write(buf, 0, bytesRead);
            fis.close();
            fis = null;
            fos.close();
            fos = null;
            rv = true;
        } catch (Throwable t) {
            throw new ApplicationException("copy error (" + source.getAbsolutePath() + " => " + dest.getAbsolutePath(), t);
        } finally {
            if (fis != null) {
                try {
                    fis.close();
                } catch (Exception e) {
                }
                fis = null;
            }
            if (fos != null) {
                try {
                    fos.close();
                } catch (Exception e) {
                }
                fos = null;
            }
        }
        return rv;
    }
public static boolean joinFiles(File dest, Collection<File> sources) {
        FileInputStream fis = null;
        FileOutputStream fos = null;
        boolean rv = false;
        byte[] buf = new byte[1000000];
        int bytesRead = 0;
        if (!dest.getParentFile().exists()) dest.getParentFile().mkdirs();
        try {
            fos = new FileOutputStream(dest);
            for (File source : sources) {
                fis = new FileInputStream(source);
                while ((bytesRead = fis.read(buf)) > 0) fos.write(buf, 0, bytesRead);
                fis.close();
                fis = null;
            }
            fos.close();
            fos = null;
            rv = true;
        } catch (Throwable t) {
            throw new ApplicationException("error joining files to " + dest.getAbsolutePath(), t);
        } finally {
            if (fis != null) {
                try {
                    fis.close();
                } catch (Exception e) {
                }
                fis = null;
            }
            if (fos != null) {
                try {
                    fos.close();
                } catch (Exception e) {
                }
                fos = null;
            }
        }
        return rv;
    }
public void testImageInfo() throws MalformedURLException, IOException {
        System.out.println("ImageInfo:");
        long start = Calendar.getInstance().getTimeInMillis();
        for (int i = 0; i < images.length; i++) {
            String url = Constants.getDefaultURIMediaConnectorBasePath() + "albums/hund/" + images[i];
            InputStream istream = (new URL(url)).openStream();
            ImageInfo ii = new ImageInfo();
            ii.setInput(istream);
            assertTrue("Not a supported image file format.", ii.check());
            int width = ii.getWidth();
            int height = ii.getHeight();
            System.out.println(width + "x" + height);
        }
        long stop = Calendar.getInstance().getTimeInMillis();
        System.out.println("zeit: " + (stop - start));
    }