semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
InputStream selectSource(String item) {
        if (item == null) {
            item = "http://pushnpop.net:8912/subpop.ogg";
        }
        if (item.endsWith(".pls")) {
            item = fetch_pls(item);
            if (item == null) {
                return null;
            }
        } else if (item.endsWith(".m3u")) {
            item = fetch_m3u(item);
            if (item == null) {
                return null;
            }
        }
        if (!item.endsWith(".ogg")) {
            return null;
        }
        InputStream is = null;
        URLConnection urlc = null;
        try {
            URL url = null;
            if (running_as_applet) {
                url = new URL(getCodeBase(), item);
            } else {
                url = new URL(item);
            }
            urlc = url.openConnection();
            is = urlc.getInputStream();
            current_source = url.getProtocol() + "://" + url.getHost() + ":" + url.getPort() + url.getFile();
        } catch (Exception ee) {
            System.err.println(ee);
        }
        if (is == null && !running_as_applet) {
            try {
                is = new FileInputStream(System.getProperty("user.dir") + System.getProperty("file.separator") + item);
                current_source = null;
            } catch (Exception ee) {
                System.err.println(ee);
            }
        }
        if (is == null) {
            return null;
        }
        System.out.println("Select: " + item);
        {
            boolean find = false;
            for (int i = 0; i < cb.getItemCount(); i++) {
                String foo = (String) (cb.getItemAt(i));
                if (item.equals(foo)) {
                    find = true;
                    break;
                }
            }
            if (!find) {
                cb.addItem(item);
            }
        }
        int i = 0;
        String s = null;
        String t = null;
        udp_port = -1;
        udp_baddress = null;
        while (urlc != null && true) {
            s = urlc.getHeaderField(i);
            t = urlc.getHeaderFieldKey(i);
            if (s == null) {
                break;
            }
            i++;
            if (t != null && t.equals("udp-port")) {
                try {
                    udp_port = Integer.parseInt(s);
                } catch (Exception ee) {
                    System.err.println(ee);
                }
            } else if (t != null && t.equals("udp-broadcast-address")) {
                udp_baddress = s;
            }
        }
        return is;
    }
String fetch_pls(String pls) {
        InputStream pstream = null;
        if (pls.startsWith("http://")) {
            try {
                URL url = null;
                if (running_as_applet) {
                    url = new URL(getCodeBase(), pls);
                } else {
                    url = new URL(pls);
                }
                URLConnection urlc = url.openConnection();
                pstream = urlc.getInputStream();
            } catch (Exception ee) {
                System.err.println(ee);
                return null;
            }
        }
        if (pstream == null && !running_as_applet) {
            try {
                pstream = new FileInputStream(System.getProperty("user.dir") + System.getProperty("file.separator") + pls);
            } catch (Exception ee) {
                System.err.println(ee);
                return null;
            }
        }
        String line = null;
        while (true) {
            try {
                line = readline(pstream);
            } catch (Exception e) {
            }
            if (line == null) {
                break;
            }
            if (line.startsWith("File1=")) {
                byte[] foo = line.getBytes();
                int i = 6;
                for (; i < foo.length; i++) {
                    if (foo[i] == 0x0d) {
                        break;
                    }
                }
                return line.substring(6, i);
            }
        }
        return null;
    }
String fetch_m3u(String m3u) {
        InputStream pstream = null;
        if (m3u.startsWith("http://")) {
            try {
                URL url = null;
                if (running_as_applet) {
                    url = new URL(getCodeBase(), m3u);
                } else {
                    url = new URL(m3u);
                }
                URLConnection urlc = url.openConnection();
                pstream = urlc.getInputStream();
            } catch (Exception ee) {
                System.err.println(ee);
                return null;
            }
        }
        if (pstream == null && !running_as_applet) {
            try {
                pstream = new FileInputStream(System.getProperty("user.dir") + System.getProperty("file.separator") + m3u);
            } catch (Exception ee) {
                System.err.println(ee);
                return null;
            }
        }
        String line = null;
        while (true) {
            try {
                line = readline(pstream);
            } catch (Exception e) {
            }
            if (line == null) {
                break;
            }
            return line;
        }
        return null;
    }
void loadPlaylist() {
        if (running_as_applet) {
            String s = null;
            for (int i = 0; i < 10; i++) {
                s = getParameter("jorbis.player.play." + i);
                if (s == null) {
                    break;
                }
                playlist.addElement(s);
            }
        }
        if (playlistfile == null) {
            return;
        }
        try {
            InputStream is = null;
            try {
                URL url = null;
                if (running_as_applet) {
                    url = new URL(getCodeBase(), playlistfile);
                } else {
                    url = new URL(playlistfile);
                }
                URLConnection urlc = url.openConnection();
                is = urlc.getInputStream();
            } catch (Exception ee) {
            }
            if (is == null && !running_as_applet) {
                try {
                    is = new FileInputStream(System.getProperty("user.dir") + System.getProperty("file.separator") + playlistfile);
                } catch (Exception ee) {
                }
            }
            if (is == null) {
                return;
            }
            while (true) {
                String line = readline(is);
                if (line == null) {
                    break;
                }
                byte[] foo = line.getBytes();
                for (int i = 0; i < foo.length; i++) {
                    if (foo[i] == 0x0d) {
                        line = new String(foo, 0, i);
                        break;
                    }
                }
                playlist.addElement(line);
            }
        } catch (Exception e) {
            System.out.println(e);
        }
    }
protected Control createContents(Composite parent) {
        this.getShell().setText("Chisio");
        this.getShell().setSize(800, 600);
        this.getShell().setImage(ImageDescriptor.createFromFile(ChisioMain.class, "icon/chisio-icon.png").createImage());
        Composite composite = new Composite(parent, SWT.BORDER);
        composite.setLayout(new FillLayout());
        this.viewer = new ScrollingGraphicalViewer();
        this.viewer.setEditDomain(this.editDomain);
        this.viewer.createControl(composite);
        this.viewer.getControl().setBackground(ColorConstants.white);
        this.rootEditPart = new ChsScalableRootEditPart();
        this.viewer.setRootEditPart(this.rootEditPart);
        this.viewer.setEditPartFactory(new ChsEditPartFactory());
        ((FigureCanvas) this.viewer.getControl()).setScrollBarVisibility(FigureCanvas.ALWAYS);
        this.viewer.addDropTargetListener(new ChsFileDropTargetListener(this.viewer, this));
        this.viewer.addDragSourceListener(new ChsFileDragSourceListener(this.viewer));
        CompoundModel model = new CompoundModel();
        model.setAsRoot();
        this.viewer.setContents(model);
        this.viewer.getControl().addMouseListener(this);
        this.popupManager = new PopupManager(this);
        this.popupManager.setRemoveAllWhenShown(true);
        this.popupManager.addMenuListener(new IMenuListener() {

            public void menuAboutToShow(IMenuManager manager) {
                ChisioMain.this.popupManager.createActions(manager);
            }
        });
        KeyHandler keyHandler = new KeyHandler();
        ActionRegistry a = new ActionRegistry();
        keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), new DeleteAction(this.viewer));
        keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), new ZoomAction(this, 1, null));
        keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), new ZoomAction(this, -1, null));
        keyHandler.put(KeyStroke.getPressed(SWT.F2, 0), a.getAction(GEFActionConstants.DIRECT_EDIT));
        this.viewer.setKeyHandler(keyHandler);
        this.higlightColor = ColorConstants.yellow;
        this.createCombos();
        return composite;
    }
public String getWebcontent(final String link, final String postdata) {
        final StringBuffer response = new StringBuffer();
        try {
            DisableSSLCertificateCheckUtil.disableChecks();
            final URL url = new URL(link);
            final URLConnection conn = url.openConnection();
            conn.setDoOutput(true);
            final OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
            wr.write(postdata);
            wr.flush();
            final BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String content = "";
            while ((content = rd.readLine()) != null) {
                response.append(content);
                response.append('\n');
            }
            wr.close();
            rd.close();
        } catch (final Exception e) {
            LOG.error("getWebcontent(String link, String postdata): " + e.toString() + "\012" + link + "\012" + postdata);
        }
        return response.toString();
    }
public static Hashtable DefaultLoginValues(String firstName, String lastName, String password, String mac, String startLocation, int major, int minor, int patch, int build, String platform, String viewerDigest, String userAgent, String author) throws Exception {
        Hashtable values = new Hashtable();
        MessageDigest md5 = MessageDigest.getInstance("MD5");
        md5.update(password.getBytes("ASCII"), 0, password.length());
        byte[] raw_digest = md5.digest();
        String passwordDigest = Helpers.toHexText(raw_digest);
        values.put("first", firstName);
        values.put("last", lastName);
        values.put("passwd", "" + password);
        values.put("start", startLocation);
        values.put("major", major);
        values.put("minor", minor);
        values.put("patch", patch);
        values.put("build", build);
        values.put("platform", platform);
        values.put("mac", mac);
        values.put("agree_to_tos", "true");
        values.put("viewer_digest", viewerDigest);
        values.put("user-agent", userAgent + " (" + Helpers.VERSION + ")");
        values.put("author", author);
        Vector optionsArray = new Vector();
        optionsArray.addElement("inventory-root");
        optionsArray.addElement("inventory-skeleton");
        optionsArray.addElement("inventory-lib-root");
        optionsArray.addElement("inventory-lib-owner");
        optionsArray.addElement("inventory-skel-lib");
        optionsArray.addElement("initial-outfit");
        optionsArray.addElement("gestures");
        optionsArray.addElement("event_categories");
        optionsArray.addElement("event_notifications");
        optionsArray.addElement("classified_categories");
        optionsArray.addElement("buddy-list");
        optionsArray.addElement("ui-config");
        optionsArray.addElement("login-flags");
        optionsArray.addElement("global-textures");
        values.put("options", optionsArray);
        return values;
    }
public static String md5(String senha) {
        MessageDigest md = null;
        try {
            md = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            System.out.println("Ocorreu NoSuchAlgorithmException");
        }
        md.update(senha.getBytes());
        byte[] xx = md.digest();
        String n2 = null;
        StringBuffer resposta = new StringBuffer();
        for (int i = 0; i < xx.length; i++) {
            n2 = Integer.toHexString(0XFF & ((int) (xx[i])));
            if (n2.length() < 2) {
                n2 = "0" + n2;
            }
            resposta.append(n2);
        }
        return resposta.toString();
    }
public void prepareWorkingDirectory() throws Exception {
        workingDirectory = tempDir + "/profile_" + System.nanoTime();
        (new File(workingDirectory)).mkdir();
        String monitorCallShellScript = "data/scripts/monitorcall.sh";
        URL monitorCallShellScriptUrl = Thread.currentThread().getContextClassLoader().getResource(monitorCallShellScript);
        File inScriptFile = null;
        try {
            inScriptFile = new File(monitorCallShellScriptUrl.toURI());
        } catch (URISyntaxException e) {
            throw e;
        }
        monitorShellScript = workingDirectory + "/monitorcall.sh";
        File outScriptFile = new File(monitorShellScript);
        FileChannel inChannel = new FileInputStream(inScriptFile).getChannel();
        FileChannel outChannel = new FileOutputStream(outScriptFile).getChannel();
        try {
            inChannel.transferTo(0, inChannel.size(), outChannel);
        } catch (IOException e) {
            throw e;
        } finally {
            if (inChannel != null) inChannel.close();
            if (outChannel != null) outChannel.close();
        }
        try {
            LinuxCommandExecutor cmdExecutor = new LinuxCommandExecutor();
            cmdExecutor.runCommand("chmod 777 " + monitorShellScript);
        } catch (Exception e) {
            throw e;
        }
    }
public static int[] sort(int[] v) {
        int i;
        int l = v.length;
        int[] index = new int[l];
        for (i = 0; i < l; i++) index[i] = i;
        int tmp;
        boolean change = true;
        while (change) {
            change = false;
            for (i = 0; i < l - 1; i++) {
                if (v[index[i]] > v[index[i + 1]]) {
                    tmp = index[i];
                    index[i] = index[i + 1];
                    index[i + 1] = tmp;
                    change = true;
                }
            }
        }
        return index;
    }
public Vector<Question> reload() throws IOException {
        Vector<Question> questions = new Vector<Question>();
        InputStream is = url.openStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        shortName = br.readLine();
        if (shortName != null && shortName.equals("SHORTNAME")) {
            shortName = br.readLine();
            author = br.readLine();
            if (author != null && author.equals("AUTHOR")) {
                author = br.readLine();
                description = br.readLine();
                if (description != null && description.equals("DESCRIPTION")) {
                    description = br.readLine();
                    try {
                        questions = QuestionLoader.getQuestions(br);
                    } catch (IOException ioe) {
                        ioe.printStackTrace();
                        throw ioe;
                    } finally {
                        br.close();
                        is.close();
                    }
                } else {
                    throw new IllegalArgumentException();
                }
            } else {
                throw new IllegalArgumentException();
            }
        } else {
            throw new IllegalArgumentException();
        }
        return questions;
    }
protected void configureGraphicalViewer() {
        super.configureGraphicalViewer();
        GraphicalViewer viewer = getGraphicalViewer();
        viewer.setEditPartFactory(createEditPartFactory());
        ScalableRootEditPart rootEditPart = new ScalableRootEditPart();
        viewer.setRootEditPart(rootEditPart);
        ZoomManager manager = rootEditPart.getZoomManager();
        double[] zoomLevels = new double[] { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0, 4.0, 5.0, 10.0, 20.0 };
        manager.setZoomLevels(zoomLevels);
        ArrayList zoomContributions = new ArrayList();
        zoomContributions.add(ZoomManager.FIT_ALL);
        zoomContributions.add(ZoomManager.FIT_HEIGHT);
        zoomContributions.add(ZoomManager.FIT_WIDTH);
        manager.setZoomLevelContributions(zoomContributions);
        getActionRegistry().registerAction(new ZoomInAction(manager));
        getActionRegistry().registerAction(new ZoomOutAction(manager));
        getGraphicalViewer().setKeyHandler(new GraphicalViewerKeyHandler(getGraphicalViewer()));
        String menuId = this.getClass().getName() + ".EditorContext";
        MenuManager menuMgr = new MenuManager(menuId, menuId);
        openPropertyAction = new OpenPropertyViewAction(viewer);
        openOutlineAction = new OpenOutlineViewAction(viewer);
        saveAsImageAction = new SaveAsImageAction(viewer);
        createDiagramAction(viewer);
        getSite().registerContextMenu(menuId, menuMgr, viewer);
        PrintAction printAction = new PrintAction(this);
        printAction.setImageDescriptor(UMLPlugin.getImageDescriptor("icons/print.gif"));
        getActionRegistry().registerAction(printAction);
        final DeleteAction deleteAction = new DeleteAction((IWorkbenchPart) this);
        deleteAction.setSelectionProvider(getGraphicalViewer());
        getActionRegistry().registerAction(deleteAction);
        viewer.addSelectionChangedListener(new ISelectionChangedListener() {

            public void selectionChanged(SelectionChangedEvent event) {
                deleteAction.update();
            }
        });
        menuMgr.add(new Separator("edit"));
        menuMgr.add(getActionRegistry().getAction(ActionFactory.DELETE.getId()));
        menuMgr.add(getActionRegistry().getAction(ActionFactory.UNDO.getId()));
        menuMgr.add(getActionRegistry().getAction(ActionFactory.REDO.getId()));
        menuMgr.add(new Separator("zoom"));
        menuMgr.add(getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
        menuMgr.add(getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT));
        fillDiagramPopupMenu(menuMgr);
        menuMgr.add(new Separator("print"));
        menuMgr.add(saveAsImageAction);
        menuMgr.add(printAction);
        menuMgr.add(new Separator("views"));
        menuMgr.add(openPropertyAction);
        menuMgr.add(openOutlineAction);
        menuMgr.add(new Separator("generate"));
        menuMgr.add(new Separator("additions"));
        viewer.setContextMenu(menuMgr);
        viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer).setParent(getCommonKeyHandler()));
    }
public boolean checkTypeChange(Class<?> clazz, File buildDir, File refFile) throws MojoExecutionException {
        if (!clazz.isPrimitive()) {
            ClassLoader cl = clazz.getClassLoader();
            if (cl == loader) {
                if (clazz.isArray()) return checkTypeChange(getArrayType(clazz), buildDir, refFile);
                String path = clazz.getName().replace('.', File.separatorChar) + ".class";
                File file = new File(buildDir, path);
                long lastMod = Long.MAX_VALUE;
                if (!file.exists()) {
                    URL url = cl.getResource(path);
                    if (url == null) throw new MojoExecutionException("Can't get URL for webservice class '" + clazz.getName() + "' from jar file."); else {
                        try {
                            JarURLConnection con = (JarURLConnection) url.openConnection();
                            lastMod = con.getJarEntry().getTime();
                        } catch (IOException x) {
                            throw new MojoExecutionException("Can't get modification time for webservice class '" + clazz.getName() + "' from jar file.");
                        }
                    }
                } else {
                    lastMod = file.lastModified();
                }
                if (refFile.lastModified() < lastMod) return true;
                if (clazz.isInterface()) {
                    Class<?>[] itfs = clazz.getInterfaces();
                    for (int i = 0; i < itfs.length; i++) {
                        boolean changed = checkTypeChange(itfs[i], buildDir, refFile);
                        if (changed) return true;
                    }
                } else {
                    Class<?> sup = clazz.getSuperclass();
                    boolean changed = checkTypeChange(sup, buildDir, refFile);
                    if (changed) return true;
                }
            }
        }
        return false;
    }
private static List retrieveQuotes(Report report, Symbol symbol, String prefix, TradingDate startDate, TradingDate endDate) throws ImportExportException {
        List quotes = new ArrayList();
        String URLString = constructURL(symbol, prefix, startDate, endDate);
        EODQuoteFilter filter = new GoogleEODQuoteFilter(symbol);
        PreferencesManager.ProxyPreferences proxyPreferences = PreferencesManager.getProxySettings();
        try {
            URL url = new URL(URLString);
            InputStreamReader input = new InputStreamReader(url.openStream());
            BufferedReader bufferedInput = new BufferedReader(input);
            String line = bufferedInput.readLine();
            while (line != null) {
                line = bufferedInput.readLine();
                if (line != null) {
                    try {
                        EODQuote quote = filter.toEODQuote(line);
                        quotes.add(quote);
                        verify(report, quote);
                    } catch (QuoteFormatException e) {
                        report.addError(Locale.getString("GOOGLE_DISPLAY_URL") + ":" + symbol + ":" + Locale.getString("ERROR") + ": " + e.getMessage());
                    }
                }
            }
            bufferedInput.close();
        } catch (BindException e) {
            throw new ImportExportException(Locale.getString("UNABLE_TO_CONNECT_ERROR", e.getMessage()));
        } catch (ConnectException e) {
            throw new ImportExportException(Locale.getString("UNABLE_TO_CONNECT_ERROR", e.getMessage()));
        } catch (UnknownHostException e) {
            throw new ImportExportException(Locale.getString("UNKNOWN_HOST_ERROR", e.getMessage()));
        } catch (NoRouteToHostException e) {
            throw new ImportExportException(Locale.getString("DESTINATION_UNREACHABLE_ERROR", e.getMessage()));
        } catch (MalformedURLException e) {
            throw new ImportExportException(Locale.getString("INVALID_PROXY_ERROR", proxyPreferences.host, proxyPreferences.port));
        } catch (FileNotFoundException e) {
        } catch (IOException e) {
            throw new ImportExportException(Locale.getString("ERROR_DOWNLOADING_QUOTES"));
        }
        return quotes;
    }
private static File createFileFromURL(URL url) throws IOException {
        File tempFile = File.createTempFile("oboFile", ".obo");
        PrintStream ps = new PrintStream(tempFile);
        BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
        String line;
        while ((line = reader.readLine()) != null) {
            ps.println(line);
        }
        ps.close();
        return tempFile;
    }