semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public void run() {
        try {
            URL url = new URL("http://pokedev.org/time.php");
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            StringTokenizer s = new StringTokenizer(in.readLine());
            m_day = Integer.parseInt(s.nextToken());
            m_hour = Integer.parseInt(s.nextToken());
            m_minutes = Integer.parseInt(s.nextToken());
            in.close();
        } catch (Exception e) {
            System.out.println("ERROR: Cannot reach time server, reverting to local time");
            Calendar cal = Calendar.getInstance();
            m_hour = cal.get(Calendar.HOUR_OF_DAY);
            m_minutes = 0;
            m_day = 0;
        }
        while (m_isRunning) {
            m_minutes = m_minutes == 59 ? 0 : m_minutes + 1;
            if (m_minutes == 0) {
                if (m_hour == 23) {
                    incrementDay();
                    m_hour = 0;
                } else {
                    m_hour += 1;
                }
            }
            m_hour = m_hour == 23 ? 0 : m_hour + 1;
            if (System.currentTimeMillis() - m_lastWeatherUpdate >= 3600000) {
                generateWeather();
                m_lastWeatherUpdate = System.currentTimeMillis();
            }
            try {
                Thread.sleep(60000);
            } catch (Exception e) {
            }
        }
        System.out.println("INFO: Time Service stopped");
    }
@Override
    public boolean putDescription(String uuid, String description) throws DatabaseException {
        if (uuid == null) throw new NullPointerException("uuid");
        if (description == null) throw new NullPointerException("description");
        try {
            getConnection().setAutoCommit(false);
        } catch (SQLException e) {
            LOGGER.warn("Unable to set autocommit off", e);
        }
        boolean found = true;
        try {
            PreparedStatement findSt = getConnection().prepareStatement(SELECT_COMMON_DESCRIPTION_STATEMENT);
            PreparedStatement updSt = null;
            findSt.setString(1, uuid);
            ResultSet rs = findSt.executeQuery();
            found = rs.next();
            int modified = 0;
            updSt = getConnection().prepareStatement(found ? UPDATE_COMMON_DESCRIPTION_STATEMENT : INSERT_COMMON_DESCRIPTION_STATEMENT);
            updSt.setString(1, description);
            updSt.setString(2, uuid);
            modified = updSt.executeUpdate();
            if (modified == 1) {
                getConnection().commit();
                LOGGER.debug("DB has been updated. Queries: \"" + findSt + "\" and \"" + updSt + "\"");
            } else {
                getConnection().rollback();
                LOGGER.error("DB has not been updated -> rollback! Queries: \"" + findSt + "\" and \"" + updSt + "\"");
                found = false;
            }
        } catch (SQLException e) {
            LOGGER.error(e);
            found = false;
        } finally {
            closeConnection();
        }
        return found;
    }
@Override
    public boolean putUserDescription(String openID, String uuid, String description) throws DatabaseException {
        if (uuid == null) throw new NullPointerException("uuid");
        if (description == null) throw new NullPointerException("description");
        try {
            getConnection().setAutoCommit(false);
        } catch (SQLException e) {
            LOGGER.warn("Unable to set autocommit off", e);
        }
        boolean found = true;
        try {
            int modified = 0;
            PreparedStatement updSt = getConnection().prepareStatement(UPDATE_USER_DESCRIPTION_STATEMENT);
            updSt.setString(1, description);
            updSt.setString(2, uuid);
            updSt.setString(3, openID);
            modified = updSt.executeUpdate();
            if (modified == 1) {
                getConnection().commit();
                LOGGER.debug("DB has been updated. Query: \"" + updSt + "\"");
            } else {
                getConnection().rollback();
                LOGGER.error("DB has not been updated -> rollback!  Query: \"" + updSt + "\"");
                found = false;
            }
        } catch (SQLException e) {
            LOGGER.error(e);
            found = false;
        } finally {
            closeConnection();
        }
        return found;
    }
private static void copyFile(File source, File dest) throws IOException {
        FileChannel srcChannel = new FileInputStream(source).getChannel();
        FileChannel dstChannel = new FileOutputStream(dest).getChannel();
        dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
        srcChannel.close();
        dstChannel.close();
    }
public void copyFile(String source_name, String dest_name) throws IOException {
        File source_file = new File(source_name);
        File destination_file = new File(dest_name);
        FileInputStream source = null;
        FileOutputStream destination = null;
        byte[] buffer;
        int bytes_read;
        try {
            if (!source_file.exists() || !source_file.isFile()) throw new FileCopyException(MM.PHRASES.getPhrase("25") + " " + source_name);
            if (!source_file.canRead()) throw new FileCopyException(MM.PHRASES.getPhrase("26") + " " + MM.PHRASES.getPhrase("27") + ": " + source_name);
            if (destination_file.exists()) {
                if (destination_file.isFile()) {
                    DataInputStream in = new DataInputStream(System.in);
                    String response;
                    if (!destination_file.canWrite()) throw new FileCopyException(MM.PHRASES.getPhrase("28") + " " + MM.PHRASES.getPhrase("29") + ": " + dest_name);
                    System.out.print(MM.PHRASES.getPhrase("19") + dest_name + MM.PHRASES.getPhrase("30") + ": ");
                    System.out.flush();
                    response = in.readLine();
                    if (!response.equals("Y") && !response.equals("y")) throw new FileCopyException(MM.PHRASES.getPhrase("31"));
                } else throw new FileCopyException(MM.PHRASES.getPhrase("28") + " " + MM.PHRASES.getPhrase("32") + ": " + dest_name);
            } else {
                File parentdir = parent(destination_file);
                if (!parentdir.exists()) throw new FileCopyException(MM.PHRASES.getPhrase("28") + " " + MM.PHRASES.getPhrase("33") + ": " + dest_name);
                if (!parentdir.canWrite()) throw new FileCopyException(MM.PHRASES.getPhrase("28") + " " + MM.PHRASES.getPhrase("34") + ": " + dest_name);
            }
            source = new FileInputStream(source_file);
            destination = new FileOutputStream(destination_file);
            buffer = new byte[1024];
            while (true) {
                bytes_read = source.read(buffer);
                if (bytes_read == -1) break;
                destination.write(buffer, 0, bytes_read);
            }
        } finally {
            if (source != null) try {
                source.close();
            } catch (IOException e) {
                ;
            }
            if (destination != null) try {
                destination.close();
            } catch (IOException e) {
                ;
            }
        }
    }
public void copyFile2(String src, String dest) throws IOException {
        FileWriter fw = null;
        FileReader fr = null;
        BufferedReader br = null;
        BufferedWriter bw = null;
        File source = null;
        try {
            fr = new FileReader(src);
            fw = new FileWriter(dest);
            br = new BufferedReader(fr);
            bw = new BufferedWriter(fw);
            source = new File(src);
            int fileLength = (int) source.length();
            char charBuff[] = new char[fileLength];
            while (br.read(charBuff, 0, fileLength) != -1) bw.write(charBuff, 0, fileLength);
        } catch (FileNotFoundException fnfe) {
            throw new FileCopyException(src + " " + MM.PHRASES.getPhrase("35"));
        } catch (IOException ioe) {
            throw new FileCopyException(MM.PHRASES.getPhrase("36"));
        } finally {
            try {
                if (br != null) br.close();
                if (bw != null) bw.close();
            } catch (IOException ioe) {
            }
        }
    }
private String getMAC(String password) {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("SHA");
        } catch (NoSuchAlgorithmException e) {
        }
        try {
            md.update(password.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
        }
        byte raw[] = md.digest();
        String hash = (new BASE64Encoder()).encode(raw);
        return hash;
    }
public void fillData() {
        try {
            URL urlhome = OpenerIF.class.getResource("Home.html");
            URLConnection uc = urlhome.openConnection();
            InputStreamReader input = new InputStreamReader(uc.getInputStream());
            BufferedReader in = new BufferedReader(input);
            String inputLine;
            String htmlData = "";
            while ((inputLine = in.readLine()) != null) {
                htmlData += inputLine;
            }
            in.close();
            String[] str = new String[9];
            str[0] = getLibName();
            str[1] = getLoginId();
            str[2] = getLoginName();
            str[3] = getVerusSubscriptionIdHTML();
            str[4] = getPendingJobsHTMLCode();
            str[5] = getFrequentlyUsedScreensHTMLCode();
            str[6] = getOpenCatalogHTMLCode();
            str[7] = getNewsHTML();
            str[8] = getOnlineInformationHTML();
            MessageFormat mf = new MessageFormat(htmlData);
            String htmlContent = mf.format(htmlData, str);
            PrintWriter fw = new PrintWriter(System.getProperty("user.home") + "/homeNGL.html");
            fw.println(htmlContent);
            fw.flush();
            fw.close();
            new LocalHtmlRendererContext(panel, new SimpleUserAgentContext(), this).navigate("file:" + System.getProperty("user.home") + "/homeNGL.html");
        } catch (Exception exp) {
            exp.printStackTrace();
        }
    }
@Override
    public void run() {
        try {
            URL urlhome = new URL("http://www.verussolutions.biz/NGLDashBoard.xml");
            URLConnection uc = urlhome.openConnection();
            InputStreamReader input = new InputStreamReader(uc.getInputStream());
            BufferedReader in = new BufferedReader(input);
            String inputLine;
            String xmlData = "";
            while ((inputLine = in.readLine()) != null) {
                xmlData += inputLine;
            }
            in.close();
            PrintWriter fw = new PrintWriter(new FileWriter(System.getProperty("user.home") + "/NGLDashBoard.xml"));
            fw.println(xmlData);
            fw.flush();
            fw.close();
        } catch (Exception exp) {
            exp.printStackTrace();
        }
        try {
            Document doc = new SAXBuilder().build(new File(System.getProperty("user.home") + "/NGLDashBoard.xml"));
            String onlinsuppcdat = doc.getRootElement().getChild("OnlineSupportInformation").getText();
            CDATA cdata = new CDATA(onlinsuppcdat);
            host.setOnlineInformationHTML(cdata.getText());
            onlinsuppcdat = doc.getRootElement().getChild("News").getText();
            cdata = new CDATA(onlinsuppcdat);
            host.setNewsHTML(cdata.getText());
            host.fillData();
        } catch (Exception exp) {
            exp.printStackTrace();
        }
    }
public String digestResponse() {
        String digest = null;
        if (null == nonce) return null;
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(username.getBytes());
            md.update(":".getBytes());
            md.update(realm.getBytes());
            md.update(":".getBytes());
            md.update(password.getBytes());
            byte[] d = md.digest();
            if (null != algorithm && -1 != (algorithm.toLowerCase()).indexOf("md5-sess")) {
                md = MessageDigest.getInstance("MD5");
                md.update(d);
                md.update(":".getBytes());
                md.update(nonce.getBytes());
                md.update(":".getBytes());
                md.update(cnonce.getBytes());
                d = md.digest();
            }
            byte[] a1 = bytesToHex(d);
            md = MessageDigest.getInstance("MD5");
            md.update(method.getBytes());
            md.update(":".getBytes());
            md.update(uri.getBytes());
            d = md.digest();
            byte[] a2 = bytesToHex(d);
            md = MessageDigest.getInstance("MD5");
            md.update(a1);
            md.update(":".getBytes());
            md.update(nonce.getBytes());
            md.update(":".getBytes());
            if (null != qop) {
                md.update(nonceCount.getBytes());
                md.update(":".getBytes());
                md.update(cnonce.getBytes());
                md.update(":".getBytes());
                md.update(qop.getBytes());
                md.update(":".getBytes());
            }
            md.update(a2);
            d = md.digest();
            byte[] r = bytesToHex(d);
            digest = new String(r);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return digest;
    }
private static boolean CopyFile(File srcFile, File tagFile) throws IOException {
        if (srcFile == null || tagFile == null) {
            return false;
        }
        int length = 2097152;
        File dirFile = new File(getFileFolder(tagFile.getAbsolutePath()));
        if (!dirFile.exists()) {
            dirFile.mkdirs();
        }
        FileInputStream in = new FileInputStream(srcFile);
        FileOutputStream out = new FileOutputStream(tagFile.getAbsolutePath());
        FileChannel inC = in.getChannel();
        FileChannel outC = out.getChannel();
        int i = 0;
        while (true) {
            if (inC.position() == inC.size()) {
                inC.close();
                outC.close();
                break;
            }
            if ((inC.size() - inC.position()) < 20971520) length = (int) (inC.size() - inC.position()); else length = 20971520;
            inC.transferTo(inC.position(), length, outC);
            inC.position(inC.position() + length);
            i++;
        }
        return true;
    }
public void search() throws Exception {
        URL searchurl = new URL("" + "http://www.ncbi.nlm.nih.gov/blast/Blast.cgi" + "?CMD=Put" + "&DATABASE=" + this.database + "&PROGRAM=" + this.program + "&QUERY=" + this.sequence.seqString());
        BufferedReader reader = new BufferedReader(new InputStreamReader(searchurl.openStream(), "UTF-8"));
        String line = "";
        while ((line = reader.readLine()) != null) {
            if (line.contains("Request ID")) this.rid += line.substring(70, 81);
        }
        reader.close();
    }
public static boolean copyFile(String sourceFileName, String destFileName) {
        FileChannel ic = null;
        FileChannel oc = null;
        try {
            ic = new FileInputStream(sourceFileName).getChannel();
            oc = new FileOutputStream(destFileName).getChannel();
            ic.transferTo(0, ic.size(), oc);
            return true;
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                ic.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                oc.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return false;
    }
public boolean compile(URL url) {
        try {
            final InputStream stream = url.openStream();
            final InputSource input = new InputSource(stream);
            input.setSystemId(url.toString());
            return compile(input, _className);
        } catch (IOException e) {
            _parser.reportError(Constants.FATAL, new ErrorMsg(e));
            return false;
        }
    }
public boolean compile(URL url, String name) {
        try {
            final InputStream stream = url.openStream();
            final InputSource input = new InputSource(stream);
            input.setSystemId(url.toString());
            return compile(input, name);
        } catch (IOException e) {
            _parser.reportError(Constants.FATAL, new ErrorMsg(e));
            return false;
        }
    }
public static String post(String actionUrl, Map<String, String> params, FormFile[] files) {
        try {
            String BOUNDARY = "---------7d4a6d158c9";
            String MULTIPART_FORM_DATA = "multipart/form-data";
            URL url = new URL(actionUrl);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setConnectTimeout(6 * 1000);
            conn.setDoInput(true);
            conn.setDoOutput(true);
            conn.setUseCaches(false);
            conn.setRequestMethod("POST");
            conn.setRequestProperty("Connection", "Keep-Alive");
            conn.setRequestProperty("Charset", "UTF-8");
            conn.setRequestProperty("Content-Type", MULTIPART_FORM_DATA + "; boundary=" + BOUNDARY);
            StringBuilder sb = new StringBuilder();
            for (Map.Entry<String, String> entry : params.entrySet()) {
                sb.append("--");
                sb.append(BOUNDARY);
                sb.append("\r\n");
                sb.append("Content-Disposition: form-data; name=\"" + entry.getKey() + "\"\r\n\r\n");
                sb.append(entry.getValue());
                sb.append("\r\n");
            }
            DataOutputStream outStream = new DataOutputStream(conn.getOutputStream());
            outStream.write(sb.toString().getBytes());
            for (FormFile file : files) {
                StringBuilder split = new StringBuilder();
                split.append("--");
                split.append(BOUNDARY);
                split.append("\r\n");
                split.append("Content-Disposition: form-data;name=\"" + file.getFileName() + "\";filename=\"" + file.getFileName() + "\"\r\n");
                split.append("Content-Type: " + file.getContentType() + "\r\n\r\n");
                outStream.write(split.toString().getBytes());
                outStream.write(file.getFileData(), 0, file.getFileData().length);
                outStream.write("\r\n".getBytes());
            }
            byte[] end_data = ("--" + BOUNDARY + "--\r\n").getBytes();
            outStream.write(end_data);
            outStream.flush();
            int cah = conn.getResponseCode();
            if (cah != 200) throw new RuntimeException("request URL failed");
            InputStream is = conn.getInputStream();
            int ch;
            StringBuilder b = new StringBuilder();
            while ((ch = is.read()) != -1) {
                b.append((char) ch);
            }
            Log.i("ItcastHttpPost", b.toString());
            outStream.close();
            conn.disconnect();
            return b.toString();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
public static String post(String actionUrl, Map<String, String> params) {
        HttpPost httpPost = new HttpPost(actionUrl);
        List<NameValuePair> list = new ArrayList<NameValuePair>();
        for (Map.Entry<String, String> entry : params.entrySet()) {
            list.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
        }
        try {
            httpPost.setEntity(new UrlEncodedFormEntity(list, HTTP.UTF_8));
            HttpResponse httpResponse = new DefaultHttpClient().execute(httpPost);
            if (httpResponse.getStatusLine().getStatusCode() == 200) {
                return EntityUtils.toString(httpResponse.getEntity());
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return null;
    }
public void sendShape(String s) {
        try {
            URLConnection uc = new URL(url + "&add=" + s).openConnection();
            InputStream in = uc.getInputStream();
            int b;
            while ((b = in.read()) != -1) {
            }
            in.close();
        } catch (IOException ex) {
            ex.printStackTrace();
        }
    }
byte[] toByteArray() throws IOException {
        DataElement element = new DataElement(DataElement.DATSEQ);
        final boolean sort = true;
        if (sort) {
            int[] sortIDs = new int[attributes.size()];
            int k = 0;
            for (Enumeration e = attributes.keys(); e.hasMoreElements(); ) {
                Integer key = (Integer) e.nextElement();
                sortIDs[k] = key.intValue();
                k++;
            }
            for (int i = 0; i < sortIDs.length; i++) {
                for (int j = 0; j < sortIDs.length - i - 1; j++) {
                    if (sortIDs[j] > sortIDs[j + 1]) {
                        int temp = sortIDs[j];
                        sortIDs[j] = sortIDs[j + 1];
                        sortIDs[j + 1] = temp;
                    }
                }
            }
            for (int i = 0; i < sortIDs.length; i++) {
                element.addElement(new DataElement(DataElement.U_INT_2, sortIDs[i]));
                element.addElement(getAttributeValue(sortIDs[i]));
            }
        } else {
            for (Enumeration e = attributes.keys(); e.hasMoreElements(); ) {
                Integer key = (Integer) e.nextElement();
                element.addElement(new DataElement(DataElement.U_INT_2, key.intValue()));
                element.addElement((DataElement) attributes.get(key));
            }
        }
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        (new SDPOutputStream(out)).writeElement(element);
        return out.toByteArray();
    }
public boolean populateRecord(int[] attrIDs) throws IOException {
        if (device == null) {
            throw new RuntimeException("This is local device service record");
        }
        if (attrIDs == null) {
            throw new NullPointerException("attrIDs is null");
        }
        if (attrIDs.length == 0) {
            throw new IllegalArgumentException();
        }
        for (int i = 0; i < attrIDs.length; i++) {
            if (attrIDs[i] < 0x0000 || attrIDs[i] > 0xffff) {
                throw new IllegalArgumentException();
            }
        }
        int[] sortIDs = new int[attrIDs.length];
        System.arraycopy(attrIDs, 0, sortIDs, 0, attrIDs.length);
        for (int i = 0; i < sortIDs.length; i++) {
            for (int j = 0; j < sortIDs.length - i - 1; j++) {
                if (sortIDs[j] > sortIDs[j + 1]) {
                    int temp = sortIDs[j];
                    sortIDs[j] = sortIDs[j + 1];
                    sortIDs[j + 1] = temp;
                }
            }
        }
        for (int i = 0; i < sortIDs.length - 1; i++) {
            if (sortIDs[i] == sortIDs[i + 1]) {
                throw new IllegalArgumentException();
            }
            DebugLog.debug0x("query for ", sortIDs[i]);
        }
        DebugLog.debug0x("query for ", sortIDs[sortIDs.length - 1]);
        return this.bluetoothStack.populateServicesRecordAttributeValues(this, sortIDs);
    }
public static void copyFile(File in, File out) throws IOException {
        FileChannel inChannel = new FileInputStream(in).getChannel();
        FileChannel outChannel = new FileOutputStream(out).getChannel();
        try {
            int maxCount = (64 * 1024 * 1024) - (32 * 1024);
            long size = inChannel.size();
            long position = 0;
            while (position < size) {
                position += inChannel.transferTo(position, maxCount, outChannel);
            }
            out.setLastModified(in.lastModified());
        } catch (IOException e) {
            throw e;
        } finally {
            if (inChannel != null) inChannel.close();
            if (outChannel != null) outChannel.close();
        }
    }