semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public synchronized void run() {
            String s;
            URL url = null;
            try {
                String localVersionS = globals.getProperty("jmathlib.version").replaceAll("/", ".");
                url = new URL(updateSiteS + "?jmathlib_version=" + localVersionS + "&command=check");
            } catch (Exception e) {
                throwMathLibException("checkForUpdates: malformed url");
            }
            Properties props = new Properties();
            try {
                props.load(url.openStream());
            } catch (Exception e) {
                ErrorLogger.debugLine("checkForUpdates: Properties error");
            }
            String localVersionS = globals.getProperty("jmathlib.version");
            String updateVersionS = props.getProperty("update.toversion");
            String updateActionS = props.getProperty("update.action");
            if (updateActionS.equals("INCREMENTAL_DOWNLOAD")) {
                if (!silentB) {
                    globals.getInterpreter().displayText("A full download ist required");
                    globals.getInterpreter().displayText("A new version " + updateVersionS + " is available");
                    globals.getInterpreter().displayText("\n Just type    update    at the prompt.");
                }
            } else if (updateActionS.equals("FULL_DOWNLOAD_REQUIRED")) {
                if (!silentB) {
                    globals.getInterpreter().displayText("A full download ist required");
                    globals.getInterpreter().displayText("A new version " + updateVersionS + " is available");
                    globals.getInterpreter().displayText("Go to www.jmathlib.de and download the latest version");
                }
            } else if (updateActionS.equals("NO_ACTION")) {
                if (!silentB) globals.getInterpreter().displayText("The local version of JMathLib is up to date");
            } else if (updateActionS.equals("VERSION_UNKNOWN")) {
                if (!silentB) globals.getInterpreter().displayText("The local version of JMathLib ist not recognized by the server");
            } else {
                globals.getInterpreter().displayText("check for updates encountered an error.");
            }
            debugLine("checkForUpdates: web:" + updateVersionS + " local:" + localVersionS);
            Calendar cal = Calendar.getInstance();
            String checkedDate = Integer.toString(cal.get(Calendar.YEAR)) + "/" + Integer.toString(cal.get(Calendar.MONTH) + 1) + "/" + Integer.toString(cal.get(Calendar.DAY_OF_MONTH));
            globals.setProperty("update.date.last", checkedDate);
            Enumeration propnames = props.propertyNames();
            while (propnames.hasMoreElements()) {
                String propName = (String) propnames.nextElement();
                String propValue = (String) props.getProperty(propName);
                ErrorLogger.debugLine("Property: " + propName + " = " + propValue);
                globals.setProperty(propName, propValue);
            }
        }
protected static void copyFile(File from, File to) throws IOException {
        if (!from.isFile() || !to.isFile()) {
            throw new IOException("Both parameters must be files. from is " + from.isFile() + ", to is " + to.isFile());
        }
        FileChannel in = (new FileInputStream(from)).getChannel();
        FileChannel out = (new FileOutputStream(to)).getChannel();
        in.transferTo(0, from.length(), out);
        in.close();
        out.close();
    }
public synchronized String encrypt(String plaintext) throws PasswordException {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("SHA");
        } catch (NoSuchAlgorithmException e) {
            throw new PasswordException(e.getMessage());
        }
        try {
            md.update(plaintext.getBytes("UTF-8"));
        } catch (UnsupportedEncodingException e) {
            throw new PasswordException(e.getMessage());
        }
        byte raw[] = md.digest();
        String hash = (new Base64Encoder()).encode(raw);
        return hash;
    }
private void runGetAppListing() {
        DataStorage.clearAppListings();
        GenericUrl url = new GoogleUrl(EnterpriseMarketplaceUrl.generateAppListingUrl() + DataStorage.getVendorProfile().vendorId);
        AppListingList appListingList;
        try {
            HttpRequest request = requestFactory.buildGetRequest(url);
            request.addParser(jsonHttpParser);
            request.readTimeout = readTimeout;
            HttpResponse response = request.execute();
            appListingList = response.parseAs(AppListingList.class);
            if (appListingList != null && appListingList.appListings != null) {
                operationStatus = true;
                DataStorage.setAppListings(appListingList.appListings);
            }
            response.getContent().close();
        } catch (IOException e) {
            AppsMarketplacePluginLog.logError(e);
        }
    }
private void runGetVendorProfile() {
        DataStorage.clearVendorProfile();
        GenericUrl url = new GoogleUrl(EnterpriseMarketplaceUrl.generateVendorProfileUrl());
        VendorProfile vendorProfile = null;
        try {
            HttpRequest request = requestFactory.buildGetRequest(url);
            request.addParser(jsonHttpParser);
            request.readTimeout = readTimeout;
            HttpResponse response = request.execute();
            vendorProfile = response.parseAs(VendorProfile.class);
            if (vendorProfile != null && vendorProfile.vendorId != null && vendorProfile.email != null && !StringUtilities.isEmpty(vendorProfile.email)) {
                DataStorage.setVendorProfile(vendorProfile);
                operationStatus = true;
            }
            response.getContent().close();
        } catch (IOException e) {
            AppsMarketplacePluginLog.logError(e);
        }
    }
private void runUpdateAppListing() {
        DataStorage.clearListedAppListing();
        GenericUrl url = new GoogleUrl(EnterpriseMarketplaceUrl.generateAppListingUrl() + DataStorage.getVendorProfile().vendorId);
        AppListing appListingBody = buildAppListing(appsMarketplaceProject);
        JsonHttpContent content = new JsonHttpContent();
        content.jsonFactory = jsonFactory;
        if (appListingBody != null) {
            content.data = appListingBody;
        }
        AppListing appListing;
        try {
            HttpRequest request = requestFactory.buildPutRequest(url, content);
            request.addParser(jsonHttpParser);
            request.readTimeout = readTimeout;
            HttpResponse response = request.execute();
            appListing = response.parseAs(AppListing.class);
            operationStatus = validateAppListing(appListing, appListingBody);
            if (operationStatus) {
                DataStorage.setListedAppListing(appListing);
            }
            response.getContent().close();
        } catch (IOException e) {
            AppsMarketplacePluginLog.logError(e);
        }
    }
private static List<InputMethodDescriptor> loadIMDescriptors() {
        String nm = SERVICES + InputMethodDescriptor.class.getName();
        Enumeration<URL> en;
        LinkedList<InputMethodDescriptor> imdList = new LinkedList<InputMethodDescriptor>();
        NativeIM nativeIM = ContextStorage.getNativeIM();
        imdList.add(nativeIM);
        try {
            en = ClassLoader.getSystemResources(nm);
            ClassLoader cl = ClassLoader.getSystemClassLoader();
            while (en.hasMoreElements()) {
                URL url = en.nextElement();
                InputStreamReader isr = new InputStreamReader(url.openStream(), "UTF-8");
                BufferedReader br = new BufferedReader(isr);
                String str = br.readLine();
                while (str != null) {
                    str = str.trim();
                    int comPos = str.indexOf("#");
                    if (comPos >= 0) {
                        str = str.substring(0, comPos);
                    }
                    if (str.length() > 0) {
                        imdList.add((InputMethodDescriptor) cl.loadClass(str).newInstance());
                    }
                    str = br.readLine();
                }
            }
        } catch (Exception e) {
        }
        return imdList;
    }
public static String encodeByMd5(String str) {
        try {
            if (str == null) {
                str = "";
            }
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(str.getBytes("utf-8"));
            byte[] b = md5.digest();
            int i;
            StringBuffer buff = new StringBuffer("");
            for (int offset = 0; offset < b.length; offset++) {
                i = b[offset];
                if (i < 0) {
                    i += 256;
                }
                if (i < 16) {
                    buff.append("0");
                }
                buff.append(Integer.toHexString(i));
            }
            return buff.toString();
        } catch (Exception e) {
            return str;
        }
    }
private void generateGuid() throws NoSuchAlgorithmException {
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        StringBuilder stringToDigest = new StringBuilder();
        long time = System.currentTimeMillis();
        long rand = random.nextLong();
        stringToDigest.append(time);
        stringToDigest.append("-");
        stringToDigest.append(rand);
        md5.update(stringToDigest.toString().getBytes());
        byte[] digestBytes = md5.digest();
        StringBuilder digest = new StringBuilder();
        for (int i = 0; i < digestBytes.length; ++i) {
            int b = digestBytes[i] & 0xFF;
            if (b < 0x10) {
                digest.append('0');
            }
            digest.append(Integer.toHexString(b));
        }
        guid = digest.toString();
    }
protected boolean downloadFile(TestThread thread, ActionResult result) {
        result.setRequestString("download file " + remoteFile);
        InputStream input = null;
        OutputStream output = null;
        OutputStream target = null;
        boolean status = false;
        ftpClient.enterLocalPassiveMode();
        try {
            if (localFile != null) {
                File lcFile = new File(localFile);
                if (lcFile.exists() && lcFile.isDirectory()) output = new FileOutputStream(new File(lcFile, remoteFile)); else output = new FileOutputStream(lcFile);
                target = output;
            } else {
                target = new FileOutputStream(remoteFile);
            }
            input = ftpClient.retrieveFileStream(remoteFile);
            long bytes = IOUtils.copy(input, target);
            status = bytes > 0;
            if (status) {
                result.setResponseLength(bytes);
            }
        } catch (Exception e) {
            result.setException(new TestActionException(config, e));
        } finally {
            IOUtils.closeQuietly(input);
            IOUtils.closeQuietly(output);
        }
        return status;
    }
public ObjectInputStream getObjectInputStreamFromServlet(String strUrl) throws Exception {
        if (headList.size() == 0) {
            return null;
        }
        String starter = "-----------------------------";
        String returnChar = "\r\n";
        String lineEnd = "--";
        String urlString = strUrl;
        String input = null;
        List txtList = new ArrayList();
        List fileList = new ArrayList();
        String targetFile = null;
        String actionStatus = null;
        StringBuffer returnMessage = new StringBuffer();
        List head = new ArrayList();
        final String boundary = String.valueOf(System.currentTimeMillis());
        URL url = null;
        URLConnection conn = null;
        DataOutputStream dos = null;
        ObjectInputStream inputFromServlet = null;
        try {
            url = new URL(baseURL, "/" + projectName + strUrl);
            conn = url.openConnection();
            ((HttpURLConnection) conn).setRequestMethod("POST");
            conn.setDoInput(true);
            conn.setDoOutput(true);
            conn.setUseCaches(false);
            conn.setRequestProperty("Content-Type", "multipart/form-data, boundary=" + "---------------------------" + boundary);
            conn.setRequestProperty("Cookie", (String) headList.get(0));
            if (input != null) {
                String auth = "Basic " + new sun.misc.BASE64Encoder().encode(input.getBytes());
                conn.setRequestProperty("Authorization", auth);
            }
            dos = new DataOutputStream(conn.getOutputStream());
            dos.flush();
            inputFromServlet = new ObjectInputStream(conn.getInputStream());
            txtList.clear();
            fileList.clear();
        } catch (EOFException e) {
            workflowEditor.getEditor().outputMessage("Session Expired!", false);
            throw e;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        } finally {
            try {
                dos.close();
            } catch (Exception e) {
            }
        }
        return inputFromServlet;
    }
public Object execute(ExecutionEvent event) throws ExecutionException {
        try {
            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            QuizTreeView view = (QuizTreeView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.rcpquizengine.views.quizzes");
            Folder rootFolder = view.getRootFolder();
            if (rootFolder.isEncrypted()) {
                PasswordDialog dialog = new PasswordDialog(shell);
                if (dialog.open() == Window.OK) {
                    String password = dialog.getPassword();
                    if (!password.equals("")) {
                        String md5 = "";
                        MessageDigest md = MessageDigest.getInstance("MD5");
                        md.update(password.getBytes());
                        md5 = new BigInteger(md.digest()).toString();
                        if (rootFolder.getMd5Digest().equals(md5)) {
                            rootFolder.setMd5Digest("");
                            rootFolder.setEncrypted(false);
                            MessageDialog.openInformation(shell, "Quiz bank unlocked", "The current quiz bank has been unlocked");
                        } else {
                            MessageDialog.openError(shell, "Error unlocking quiz bank", "Incorrect password");
                        }
                        password = "";
                        md5 = "";
                    }
                }
            } else {
                MessageDialog.openError(shell, "Error unlocking quiz bank", "Quiz bank already unlocked");
            }
        } catch (PartInitException e) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return null;
    }
public String getResponse(URL url) throws OAuthException {
        try {
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();
            connection.connect();
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String inputLine;
            StringBuilder response = new StringBuilder();
            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }
            in.close();
            return response.toString();
        } catch (IOException e) {
            throw new OAuthException("Error getting HTTP response", e);
        }
    }
@Override
    public void run() {
        try {
            FileChannel in = new FileInputStream(inputfile).getChannel();
            long pos = 0;
            for (int i = 1; i <= noofparts; i++) {
                FileChannel out = new FileOutputStream(outputfile.getAbsolutePath() + "." + "v" + i).getChannel();
                status.setText("Rozdělovač: Rozděluji část " + i + "..");
                in.transferTo(pos, splitsize, out);
                pos += splitsize;
                remainingsize -= splitsize;
                if (remainingsize < splitsize) in.transferTo(pos, remainingsize, out);
                pb.setValue(100 * i / noofparts);
                out.close();
            }
            in.close();
            if (deleteOnFinish) new File(inputfile + "").delete();
            status.setText("Rozdělovač: Hotovo..");
            JOptionPane.showMessageDialog(null, "Rozděleno!", "Rozdělovač", JOptionPane.INFORMATION_MESSAGE);
        } catch (IOException ex) {
        }
    }
private void readURL(URL url) throws IOException {
        statusLine.setText("Opening " + url.toExternalForm());
        URLConnection connection = url.openConnection();
        StringBuffer buffer = new StringBuffer();
        BufferedReader in = null;
        try {
            in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String line;
            while ((line = in.readLine()) != null) {
                buffer.append(line).append('\n');
                statusLine.setText("Read " + buffer.length() + " bytes...");
            }
        } finally {
            if (in != null) in.close();
        }
        String type = connection.getContentType();
        if (type == null) type = "text/plain";
        statusLine.setText("Content type " + type);
        content.setContentType(type);
        content.setText(buffer.toString());
        statusLine.setText("Done");
    }
public void cpFile(File source, File target, boolean replace, int bufferSize) throws IOException {
        if (!source.exists()) throw new IOException("source file not exists");
        if (!source.isFile()) throw new IOException("source file not exists(is a directory)");
        InputStream src = new FileInputStream(source);
        File tarn = target;
        if (target.isDirectory() || !(!(target.exists()) || replace)) {
            String tardir = target.isDirectory() ? target.getPath() : target.getParent();
            tarn = new File(tardir + File.separator + source.getName());
            int n = 1;
            while (!(!tarn.exists() || replace)) {
                tarn = new File(tardir + File.separator + String.valueOf(n) + " copy of " + source.getName());
                n++;
            }
        }
        if (source.getPath().equals(tarn.getPath()) && replace) return;
        OutputStream tar = new FileOutputStream(tarn);
        byte[] bytes = new byte[bufferSize];
        int readn = -1;
        while ((readn = src.read(bytes)) > 0) {
            tar.write(bytes, 0, readn);
        }
        tar.flush();
        tar.close();
        src.close();
    }
public static byte[] MD5(String input) {
        MessageDigest md5 = null;
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            return null;
        }
        md5.update(input.getBytes());
        return md5.digest();
    }
public void hyperlinkUpdate(HyperlinkEvent e) {
        if (e.getEventType() == EventType.ACTIVATED) {
            try {
                URL url = e.getURL();
                InputStream stream = url.openStream();
                try {
                    StringWriter writer = new StringWriter();
                    IOUtils.copy(stream, writer, "UTF-8");
                    JEditorPane editor = new JEditorPane("text/plain", writer.toString());
                    editor.setEditable(false);
                    editor.setBackground(Color.WHITE);
                    editor.setCaretPosition(0);
                    editor.setPreferredSize(new Dimension(600, 400));
                    String name = url.toString();
                    name = name.substring(name.lastIndexOf('/') + 1);
                    JDialog dialog = new JDialog(this, "内容解析: " + name);
                    dialog.add(new JScrollPane(editor));
                    dialog.pack();
                    dialog.setVisible(true);
                } finally {
                    stream.close();
                }
            } catch (IOException exception) {
                exception.printStackTrace();
            }
        }
    }
public void parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException {
            String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
            if (name != null && wanted.containsKey(name)) {
                FileOutputStream out = new FileOutputStream(wanted.get(name));
                IOUtils.copy(stream, out);
                out.close();
            } else {
                if (downstreamParser != null) {
                    downstreamParser.parse(stream, handler, metadata, context);
                }
            }
        }
public static void copyFile(File src, File dst) throws IOException {
        BufferedInputStream is = new BufferedInputStream(new FileInputStream(src));
        BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(dst));
        byte[] buf = new byte[1024];
        int count = 0;
        while ((count = is.read(buf, 0, 1024)) != -1) os.write(buf, 0, count);
        is.close();
        os.close();
    }
private void UploadActionPerformed(ActionEvent evt) {
        JFileChooser chooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter("*.jpg", "jpg");
        chooser.setFileFilter(filter);
        File dir = new File(System.getProperty("user.home"));
        chooser.setCurrentDirectory(dir);
        Component parent = null;
        int returnVal = chooser.showOpenDialog(parent);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            UserStatus.setText("Bitte warten");
        }
        try {
            Pic.setVisible(false);
            FTPClient client = new FTPClient();
            client.connect("showus.de");
            client.login("web2", "kcinnay88");
            client.enterLocalActiveMode();
            client.setFileTransferMode(FTPClient.BINARY_FILE_TYPE);
            client.setFileType(FTPClient.BINARY_FILE_TYPE);
            int reply = client.getReplyCode();
            System.out.println("Connect returned: " + reply);
            FileInputStream in = new FileInputStream(chooser.getSelectedFile().getAbsolutePath());
            System.out.println("Uploading File");
            client.storeFile("/html/Applet/user/" + Config.id + ".jpg", in);
            client.logout();
            in.close();
            System.out.println("done");
            UserStatus.setText("Upload fertig, Bild wird aktuallisiert");
        } catch (SocketException e) {
            e.printStackTrace();
        } catch (IOException e) {
            UserStatus.setText("Fehler beim Upload");
            e.printStackTrace();
        }
    }
private Document parseResponse(String url) throws IOException, MalformedURLException, ParserConfigurationException, SAXException {
        DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
        InputStream stream = null;
        try {
            stream = new URL(url).openStream();
            return db.parse(stream);
        } finally {
            if (stream != null) stream.close();
        }
    }
private void addPlugin(URL url) throws IOException {
        logger.debug("Adding plugin with URL {}", url);
        InputStream in = url.openStream();
        try {
            Properties properties = new Properties();
            properties.load(in);
            plugins.add(new WtfPlugin(properties));
        } finally {
            in.close();
        }
    }
public File copyFile(File in, File out) throws IOException {
        FileChannel inChannel = new FileInputStream(in).getChannel();
        FileChannel outChannel = new FileOutputStream(out).getChannel();
        copyChannel(inChannel, outChannel);
        return out;
    }