semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public APIResponse create(User user) throws Exception {
        APIResponse response = new APIResponse();
        connection = (HttpURLConnection) new URL(url + "/api/user/create").openConnection();
        connection.setDoOutput(true);
        connection.setRequestMethod("POST");
        connection.setRequestProperty("Content-Type", "application/json; charset=utf-8");
        connection.setUseCaches(false);
        connection.setConnectTimeout(TIMEOUT);
        connection.connect();
        marshaller.marshal(user, new MappedXMLStreamWriter(new MappedNamespaceConvention(new Configuration()), new OutputStreamWriter(connection.getOutputStream(), "utf-8")));
        connection.getOutputStream().flush();
        connection.getOutputStream().close();
        if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
            JSONObject obj = new JSONObject(new String(new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8")).readLine()));
            response.setDone(true);
            response.setMessage(unmarshaller.unmarshal(new MappedXMLStreamReader(obj, new MappedNamespaceConvention(new Configuration()))));
            connection.getInputStream().close();
        } else {
            response.setDone(false);
            response.setMessage("Create User Error Code: Http (" + connection.getResponseCode() + ")");
        }
        connection.disconnect();
        return response;
    }
public APIResponse delete(String id) throws Exception {
        APIResponse response = new APIResponse();
        connection = (HttpURLConnection) new URL(url + "/api/user/delete/" + id).openConnection();
        connection.setRequestMethod("DELETE");
        connection.setConnectTimeout(TIMEOUT);
        connection.connect();
        if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
            response.setDone(true);
            response.setMessage("User Deleted!");
        } else {
            response.setDone(false);
            response.setMessage("Delete User Error Code: Http (" + connection.getResponseCode() + ")");
        }
        connection.disconnect();
        return response;
    }
public APIResponse update(User user) throws Exception {
        APIResponse response = new APIResponse();
        connection = (HttpURLConnection) new URL(url + "/api/user/update").openConnection();
        connection.setDoOutput(true);
        connection.setRequestMethod("PUT");
        connection.setRequestProperty("Content-Type", "application/json; charset=utf-8");
        connection.setUseCaches(false);
        connection.setConnectTimeout(TIMEOUT);
        connection.connect();
        marshaller.marshal(user, new MappedXMLStreamWriter(new MappedNamespaceConvention(new Configuration()), new OutputStreamWriter(connection.getOutputStream(), "utf-8")));
        connection.getOutputStream().flush();
        connection.getOutputStream().close();
        if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
            JSONObject obj = new JSONObject(new String(new BufferedReader(new InputStreamReader(connection.getInputStream(), "utf-8")).readLine()));
            response.setDone(true);
            response.setMessage(unmarshaller.unmarshal(new MappedXMLStreamReader(obj, new MappedNamespaceConvention(new Configuration()))));
            connection.getInputStream().close();
        } else {
            response.setDone(false);
            response.setMessage("Update User Error Code: Http (" + connection.getResponseCode() + ")");
        }
        connection.disconnect();
        return response;
    }
private void checkChartsyRegistration(String username, String password) {
        HttpPost post = new HttpPost(NbBundle.getMessage(RegisterPanel.class, "RegisterPanel.chartsyRegisterURL"));
        String message = "";
        try {
            List<NameValuePair> nvps = new ArrayList<NameValuePair>();
            nvps.add(new BasicNameValuePair("username", username));
            nvps.add(new BasicNameValuePair("password", password));
            post.setEntity(new UrlEncodedFormEntity(nvps));
            HttpResponse response = ProxyManager.httpClient.execute(post);
            HttpEntity entity = response.getEntity();
            if (entity != null) {
                String[] lines = EntityUtils.toString(entity).split("\n");
                if (lines[0].equals("OK")) {
                    RegisterAction.preferences.putBoolean("registred", true);
                    RegisterAction.preferences.put("name", lines[1]);
                    RegisterAction.preferences.put("email", lines[2]);
                    RegisterAction.preferences.put("date", String.valueOf(Calendar.getInstance().getTimeInMillis()));
                    RegisterAction.preferences.put("username", username);
                    RegisterAction.preferences.put("password", new String(passwordTxt.getPassword()));
                    if (lines[1] != null && !lines[1].isEmpty()) {
                        message = NbBundle.getMessage(RegisterPanel.class, "RegisterPanel.registerDone.withUsername.message", lines[1]);
                    } else {
                        message = NbBundle.getMessage(RegisterPanel.class, "RegisterPanel.registerDone.noUsername.message");
                    }
                } else {
                    message = NbBundle.getMessage(RegisterPanel.class, "RegisterPanel.registerAuthError.message");
                }
                EntityUtils.consume(entity);
            }
        } catch (Exception ex) {
            message = NbBundle.getMessage(RegisterPanel.class, "RegisterPanel.registerConnectionError.message");
        } finally {
            post.abort();
        }
        messageLbl.setText(message);
        messageLbl.setVisible(true);
    }
public String uploadVideo(String ticketId, String filePath) {
        TreeMap<String, String> uploadParams = new TreeMap<String, String>();
        String url = "http://www.vimeo.com/services/upload/";
        uploadParams.put("api_key", apiKey);
        uploadParams.put("auth_token", this.TEMP_AUTH_TOKEN);
        uploadParams.put("ticket_id", ticketId);
        uploadParams.put("format", "json");
        String signature = this.generateAppSignature(uploadParams);
        uploadParams.put("api_sig", signature);
        ClientHttpRequest request = null;
        try {
            request = new ClientHttpRequest(new URL(url).openConnection());
        } catch (IOException e) {
            e.printStackTrace();
        }
        for (Entry<String, String> param : uploadParams.entrySet()) {
            try {
                request.setParameter(param.getKey(), param.getValue());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        InputStream videoInput = null;
        try {
            videoInput = new FileInputStream(filePath);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            request.setParameter("video", filePath, videoInput);
        } catch (IOException e) {
            e.printStackTrace();
        }
        InputStream response = null;
        try {
            response = request.post();
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            InputStreamReader inR = new InputStreamReader(response);
            BufferedReader buf = new BufferedReader(inR);
            String line;
            try {
                while ((line = buf.readLine()) != null) {
                    System.out.println(line);
                }
            } catch (IOException e) {
                e.printStackTrace();
            }
        } finally {
            try {
                response.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return "hey";
    }
public String performRequest(TreeMap<String, String> params, boolean isAuthenticated) {
        params.put("format", "json");
        try {
            URL url = new URL(getApiUrl(params, isAuthenticated));
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setRequestMethod("GET");
            conn.connect();
            Reader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String response = "";
            while (reader.ready()) {
                response += (char) reader.read();
            }
            response = response.replaceFirst("jsonVimeoApi\\(", "");
            response = response.substring(0, response.length() - 2);
            return response;
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
public String gerarHash(String frase) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-256");
            md.update(frase.getBytes());
            byte[] bytes = md.digest();
            StringBuilder s = new StringBuilder(0);
            for (int i = 0; i < bytes.length; i++) {
                int parteAlta = ((bytes[i] >> 4) & 0xf) << 4;
                int parteBaixa = bytes[i] & 0xf;
                if (parteAlta == 0) {
                    s.append('0');
                }
                s.append(Integer.toHexString(parteAlta | parteBaixa));
            }
            return s.toString();
        } catch (NoSuchAlgorithmException e) {
            return null;
        }
    }
public boolean write(Node node, LSOutput output) throws LSException {
        OutputStream out = output.getByteStream();
        try {
            if (out == null) {
                String systemId = output.getSystemId();
                try {
                    URL url = new URL(systemId);
                    URLConnection connection = url.openConnection();
                    connection.setDoOutput(true);
                    if (connection instanceof HttpURLConnection) {
                        ((HttpURLConnection) connection).setRequestMethod("PUT");
                    }
                    out = connection.getOutputStream();
                } catch (MalformedURLException e) {
                    File file = new File(systemId);
                    out = new FileOutputStream(file);
                }
            }
            serialize(node, out);
            out.flush();
            return true;
        } catch (IOException e) {
            throw new DomLSException(LSException.SERIALIZE_ERR, e);
        }
    }
public static SpeciesTree create(String url) throws IOException {
        SpeciesTree tree = new SpeciesTree();
        tree.setUrl(url);
        System.out.println("Fetching URL:  " + url);
        BufferedReader in = new BufferedReader(new InputStreamReader(new URL(url).openStream()));
        String toParse = null;
        Properties properties = new Properties();
        properties.load(in);
        String line = properties.getProperty("TREE");
        if (line == null) return null;
        int end = line.indexOf(';');
        if (end < 0) end = line.length();
        toParse = line.substring(0, end).trim();
        System.out.print("Parsing... ");
        parse(tree, toParse, properties);
        return tree;
    }
public void doBody(JWebLiteRequestWrapper req, JWebLiteResponseWrapper resp) throws SkipException {
        BufferedInputStream bis = null;
        BufferedOutputStream bos = null;
        try {
            bis = new BufferedInputStream(new FileInputStream(this.loadData(req)));
            bos = new BufferedOutputStream(resp.getOutputStream());
            IOUtils.copy(bis, bos);
            bos.flush();
        } catch (Exception e) {
            _cat.warn("Write data failed!", e);
        } finally {
            IOUtils.closeQuietly(bis);
            IOUtils.closeQuietly(bos);
        }
    }
public static Map<String, File> extractFiles(String input, File tempDirectory) throws IOException {
        byte data[] = new byte[BUFFER];
        BufferedOutputStream out = null;
        FileInputStream src = new FileInputStream(input);
        BufferedInputStream in = new BufferedInputStream(src);
        ZipInputStream zipin = new ZipInputStream(in);
        Map<String, File> files = new HashMap<String, File>();
        ZipEntry entry;
        while ((entry = zipin.getNextEntry()) != null) {
            logger.info(TAG + ": entr�e " + entry.getName() + " r�pertoire ? " + entry.isDirectory());
            if (entry.isDirectory()) {
                logger.info(TAG + ": Ajout de l'entr�e pour le r�pertoire: " + entry.getName());
                files.put(entry.getName(), extractDirectory(entry.getName(), zipin, tempDirectory));
                File f = files.get(entry.getName());
                if (f == null) logger.info(TAG + ": NULLL: ");
                continue;
            }
            File tempFile = new File(tempDirectory, entry.getName());
            if (tempFile.exists()) tempFile.delete();
            tempFile.createNewFile();
            FileOutputStream dest = new FileOutputStream(tempFile);
            out = new BufferedOutputStream(dest, BUFFER);
            int count;
            for (int c = zipin.read(); c != -1; c = zipin.read()) dest.write(c);
            logger.info(TAG + ": Ajout de l'entr�e: " + entry.getName() + " du fichier: " + tempFile.getAbsolutePath());
            files.put(entry.getName(), tempFile);
            out.close();
            dest.close();
        }
        zipin.close();
        in.close();
        src.close();
        return files;
    }
public void load() {
        try {
            isSourceWorking = true;
            URLConnection urlConnection = url.openConnection();
            ontologyServiceMetaData.setName("Ontology for " + url.getFile());
            parseDocument(urlConnection.getInputStream());
            buildTree();
            isSourceWorking = true;
            String statusOKMessage = PedroResources.getMessage("ontology.statusOK", url.getFile());
            status = new StringBuffer();
            status.append(statusOKMessage);
        } catch (Exception err) {
            err.printStackTrace(System.out);
            String statusErrorMessage = PedroResources.getMessage("ontology.statusError", err.toString());
            status.append(statusErrorMessage);
            isSourceWorking = false;
        }
    }
protected void cboTemplateIndexSelectionChanged() {
        int idx = WizardPage1.this.cboTemplateIndex.getSelectionIndex();
        IPreferenceStore store = Activator.getDefault().getPreferenceStore();
        String prefnamePrefix = PreferenceConstants.TEMPLATE_PREFIX + idx;
        String baseUrl = store.getString(prefnamePrefix + PreferenceConstants.BASEURL_POSTFIX);
        String descfile = store.getString(prefnamePrefix + PreferenceConstants.DESCFILE_POSTFIX);
        try {
            URL url = new URL(baseUrl + descfile);
            URLConnection con = url.openConnection();
            WizardPage1.this.setTemplContainer(new TemplateContainer(con.getInputStream(), baseUrl));
            fillListboxFromTemplateContainer();
        } catch (MalformedURLException e1) {
            getTxaTemplateDescription().setText(e1.getMessage());
            e1.printStackTrace();
        } catch (IOException e2) {
            getTxaTemplateDescription().setText(e2.getMessage());
            e2.printStackTrace();
        } catch (XPathExpressionException e3) {
            getTxaTemplateDescription().setText(e3.getMessage());
            e3.printStackTrace();
        } catch (ParserConfigurationException e4) {
            getTxaTemplateDescription().setText(e4.getMessage());
            e4.printStackTrace();
        } catch (SAXException e5) {
            getTxaTemplateDescription().setText(e5.getMessage());
            e5.printStackTrace();
        }
    }
private void read(String url) {
        session.beginTransaction();
        try {
            Document doc = reader.read(new URL(url).openStream());
            Element root = doc.getRootElement();
            Dict dic = new Dict();
            Vector<Cent> v = new Vector<Cent>();
            for (Object o : root.elements()) {
                Element e = (Element) o;
                if (e.getName().equals("key")) {
                    dic.setName(e.getTextTrim());
                } else if (e.getName().equals("audio")) {
                    dic.setAudio(e.getTextTrim());
                } else if (e.getName().equals("pron")) {
                    dic.setPron(e.getTextTrim());
                } else if (e.getName().equals("def")) {
                    dic.setDef(e.getTextTrim());
                } else if (e.getName().equals("sent")) {
                    Cent cent = new Cent();
                    for (Object subo : e.elements()) {
                        Element sube = (Element) subo;
                        if (sube.getName().equals("orig")) {
                            cent.setOrig(sube.getTextTrim());
                        } else if (sube.getName().equals("trans")) {
                            cent.setTrans(sube.getTextTrim());
                        }
                    }
                    v.add(cent);
                }
            }
            if (dic.getName() == null || "".equals(dic.getName())) {
                session.getTransaction().commit();
                return;
            }
            session.save(dic);
            dic.setCent(new HashSet<Cent>());
            for (Cent c : v) {
                c.setDict(dic);
                dic.getCent().add(c);
            }
            session.getTransaction().commit();
        } catch (Exception e) {
            e.printStackTrace();
            session.getTransaction().rollback();
        }
    }
public static void copy(String fromFile, String toFile) throws IOException {
        File inputFile = new File(fromFile);
        File outputFile = new File(toFile);
        FileReader in = new FileReader(inputFile);
        FileWriter out = new FileWriter(outputFile);
        int c;
        while ((c = in.read()) != -1) out.write(c);
        in.close();
        out.close();
    }
private static String appletLoad(String file, Output OUT) {
        if (!urlpath.endsWith("/")) {
            urlpath += '/';
        }
        if (!urlpath.startsWith("http://")) {
            urlpath = "http://" + urlpath;
        }
        String url = "";
        if (file.equals("languages.txt")) {
            url = urlpath + file;
        } else {
            url = urlpath + "users/" + file;
        }
        try {
            StringBuffer sb = new StringBuffer(2000);
            BufferedReader br = new BufferedReader(new InputStreamReader(new URL(url).openStream()));
            String a;
            while ((a = br.readLine()) != null) {
                sb.append(a).append('\n');
            }
            return sb.toString();
        } catch (Exception e) {
            OUT.println("load failed for file->" + file);
        }
        return "";
    }
public static String getSHADigest(String input) {
        if (input == null) return null;
        MessageDigest sha = null;
        try {
            sha = MessageDigest.getInstance("SHA-1");
        } catch (java.security.NoSuchAlgorithmException nsae) {
            throw new RuntimeException(nsae);
        }
        if (sha == null) throw new RuntimeException("No message digest");
        sha.update(input.getBytes());
        byte[] data = sha.digest();
        StringBuffer buf = new StringBuffer(data.length * 2);
        for (int i = 0; i < data.length; i++) {
            int value = data[i] & 0xff;
            buf.append(hexDigit(value >> 4));
            buf.append(hexDigit(value));
        }
        return buf.toString();
    }
protected String saveJar2TmpFile(String jarUrl, boolean reportError) {
        InputStream is = null;
        try {
            URL url = new URL(jad.getJarURL());
            URLConnection conn = url.openConnection();
            if (url.getUserInfo() != null) {
                String userInfo = new String(Base64Coder.encode(url.getUserInfo().getBytes("UTF-8")));
                conn.setRequestProperty("Authorization", "Basic " + userInfo);
            }
            is = conn.getInputStream();
            File tmpDir = null;
            String systemTmpDir = MIDletSystemProperties.getSystemProperty("java.io.tmpdir");
            if (systemTmpDir != null) {
                tmpDir = new File(systemTmpDir, "microemulator-apps");
                if ((!tmpDir.exists()) && (!tmpDir.mkdirs())) {
                    tmpDir = null;
                }
            }
            File tmp = File.createTempFile("me2-app-", ".jar", tmpDir);
            tmp.deleteOnExit();
            IOUtils.copyToFile(is, tmp);
            return IOUtils.getCanonicalFileClassLoaderURL(tmp);
        } catch (IOException e) {
            if (reportError) {
                Message.error("Unable to open jar " + jarUrl, e);
            }
            return null;
        } finally {
            IOUtils.closeQuietly(is);
        }
    }
private FileInputStream getPackageStream(String archivePath) throws IOException, PackageManagerException {
        final int lastSlashInName = filename.lastIndexOf("/");
        final String newFileName = filename.substring(lastSlashInName);
        File packageFile = new File((new StringBuilder()).append(archivePath).append(newFileName).toString());
        if (null != packageFile) return new FileInputStream(packageFile);
        if (null != packageURL) {
            final InputStream urlStream = new ConnectToServer(null).getInputStream(packageURL);
            packageFile = new File((new StringBuilder()).append(getName()).append(".deb").toString());
            final OutputStream fileStream = new FileOutputStream(packageFile);
            final byte buffer[] = new byte[10240];
            for (int read = 0; (read = urlStream.read(buffer)) > 0; ) fileStream.write(buffer, 0, read);
            urlStream.close();
            fileStream.close();
            return new FileInputStream(packageFile);
        } else {
            final String errorMessage = PreferenceStoreHolder.getPreferenceStoreByName("Screen").getPreferenceAsString("package.getPackageStream.packageURLIsNull", "No entry found for package.getPackageStream.packageURLIsNull");
            if (pm != null) {
                pm.addWarning(errorMessage);
                logger.error(errorMessage);
            } else logger.error(errorMessage);
            throw new FileNotFoundException();
        }
    }
public static void main(String[] args) {
        if (args.length != 2) throw new IllegalArgumentException();
        String inFileName = args[0];
        String outFileName = args[1];
        File fInput = new File(inFileName);
        Scanner in = null;
        try {
            in = new Scanner(fInput);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        PrintWriter out = null;
        try {
            out = new PrintWriter(outFileName);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        while (in.hasNextLine()) {
            out.println(in.nextLine());
        }
        in.close();
        out.close();
    }