semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
private void addAuditDatastream() throws ObjectIntegrityException, StreamIOException {
        if (m_obj.getAuditRecords().size() == 0) {
            return;
        }
        String dsId = m_pid.toURI() + "/AUDIT";
        String dsvId = dsId + "/" + DateUtility.convertDateToString(m_obj.getCreateDate());
        Entry dsEntry = m_feed.addEntry();
        dsEntry.setId(dsId);
        dsEntry.setTitle("AUDIT");
        dsEntry.setUpdated(m_obj.getCreateDate());
        dsEntry.addCategory(MODEL.STATE.uri, "A", null);
        dsEntry.addCategory(MODEL.CONTROL_GROUP.uri, "X", null);
        dsEntry.addCategory(MODEL.VERSIONABLE.uri, "false", null);
        dsEntry.addLink(dsvId, Link.REL_ALTERNATE);
        Entry dsvEntry = m_feed.addEntry();
        dsvEntry.setId(dsvId);
        dsvEntry.setTitle("AUDIT.0");
        dsvEntry.setUpdated(m_obj.getCreateDate());
        ThreadHelper.addInReplyTo(dsvEntry, m_pid.toURI() + "/AUDIT");
        dsvEntry.addCategory(MODEL.FORMAT_URI.uri, AUDIT1_0.uri, null);
        dsvEntry.addCategory(MODEL.LABEL.uri, "Audit Trail for this object", null);
        if (m_format.equals(ATOM_ZIP1_1)) {
            String name = "AUDIT.0.xml";
            try {
                m_zout.putNextEntry(new ZipEntry(name));
                Reader r = new StringReader(DOTranslationUtility.getAuditTrail(m_obj));
                IOUtils.copy(r, m_zout, m_encoding);
                m_zout.closeEntry();
                r.close();
            } catch (IOException e) {
                throw new StreamIOException(e.getMessage(), e);
            }
            IRI iri = new IRI(name);
            dsvEntry.setSummary("AUDIT.0");
            dsvEntry.setContent(iri, "text/xml");
        } else {
            dsvEntry.setContent(DOTranslationUtility.getAuditTrail(m_obj), "text/xml");
        }
    }
private void setInlineXML(Entry entry, DatastreamXMLMetadata ds) throws UnsupportedEncodingException, StreamIOException {
        String content;
        if (m_obj.hasContentModel(Models.SERVICE_DEPLOYMENT_3_0) && (ds.DatastreamID.equals("SERVICE-PROFILE") || ds.DatastreamID.equals("WSDL"))) {
            content = DOTranslationUtility.normalizeInlineXML(new String(ds.xmlContent, m_encoding), m_transContext);
        } else {
            content = new String(ds.xmlContent, m_encoding);
        }
        if (m_format.equals(ATOM_ZIP1_1)) {
            String name = ds.DSVersionID + ".xml";
            try {
                m_zout.putNextEntry(new ZipEntry(name));
                InputStream is = new ByteArrayInputStream(content.getBytes(m_encoding));
                IOUtils.copy(is, m_zout);
                m_zout.closeEntry();
                is.close();
            } catch (IOException e) {
                throw new StreamIOException(e.getMessage(), e);
            }
            IRI iri = new IRI(name);
            entry.setSummary(ds.DSVersionID);
            entry.setContent(iri, ds.DSMIME);
        } else {
            entry.setContent(content, ds.DSMIME);
        }
    }
private void setManagedContent(Entry entry, Datastream vds) throws StreamIOException {
        if (m_transContext == DOTranslationUtility.SERIALIZE_EXPORT_ARCHIVE && !m_format.equals(ATOM_ZIP1_1)) {
            String mimeType = vds.DSMIME;
            if (MimeTypeHelper.isText(mimeType) || MimeTypeHelper.isXml(mimeType)) {
                try {
                    entry.setContent(IOUtils.toString(vds.getContentStream(), m_encoding), mimeType);
                } catch (IOException e) {
                    throw new StreamIOException(e.getMessage(), e);
                }
            } else {
                entry.setContent(vds.getContentStream(), mimeType);
            }
        } else {
            String dsLocation;
            IRI iri;
            if (m_format.equals(ATOM_ZIP1_1) && m_transContext != DOTranslationUtility.AS_IS) {
                dsLocation = vds.DSVersionID + "." + MimeTypeUtils.fileExtensionForMIMEType(vds.DSMIME);
                try {
                    m_zout.putNextEntry(new ZipEntry(dsLocation));
                    InputStream is = vds.getContentStream();
                    IOUtils.copy(is, m_zout);
                    is.close();
                    m_zout.closeEntry();
                } catch (IOException e) {
                    throw new StreamIOException(e.getMessage(), e);
                }
            } else {
                dsLocation = StreamUtility.enc(DOTranslationUtility.normalizeDSLocationURLs(m_obj.getPid(), vds, m_transContext).DSLocation);
            }
            iri = new IRI(dsLocation);
            entry.setSummary(vds.DSVersionID);
            entry.setContent(iri, vds.DSMIME);
        }
    }
public static URLConnection createConnection(URL url) throws java.io.IOException {
        URLConnection urlConn = url.openConnection();
        if (urlConn instanceof HttpURLConnection) {
            HttpURLConnection httpConn = (HttpURLConnection) urlConn;
            httpConn.setRequestMethod("POST");
        }
        urlConn.setDoInput(true);
        urlConn.setDoOutput(true);
        urlConn.setUseCaches(false);
        urlConn.setDefaultUseCaches(false);
        return urlConn;
    }
protected void copyFile(String inputFilePath, String outputFilePath) throws GenerationException {
        String from = getTemplateDir() + inputFilePath;
        try {
            logger.debug("Copying from " + from + " to " + outputFilePath);
            InputStream inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(from);
            if (inputStream == null) {
                throw new GenerationException("Source file not found: " + from);
            }
            FileOutputStream outputStream = new FileOutputStream(new File(outputFilePath));
            IOUtils.copy(inputStream, outputStream);
            inputStream.close();
            outputStream.close();
        } catch (Exception e) {
            throw new GenerationException("Error while copying file: " + from, e);
        }
    }
private boolean serverOK(String serverAddress, String serverPort) {
        boolean status = false;
        String serverString = serverAddress + ":" + serverPort + MolConvertInNodeModel.SERVER_WSDL_PATH;
        System.out.println("connecting to " + serverString + "...");
        try {
            java.net.URL url = new java.net.URL(serverString);
            try {
                java.net.HttpURLConnection connection = (java.net.HttpURLConnection) url.openConnection();
                status = readContents(connection);
                if (status) {
                    JOptionPane.showMessageDialog(this.getPanel(), "Connection to Server is OK");
                }
            } catch (Exception connEx) {
                JOptionPane.showMessageDialog(this.getPanel(), connEx.getMessage());
                logger.error(connEx.getMessage());
            }
        } catch (java.net.MalformedURLException urlEx) {
            JOptionPane.showMessageDialog(this.getPanel(), urlEx.getMessage());
            logger.error(urlEx.getMessage());
        }
        return status;
    }
public static int[] bubbleSort(int[] source) {
        if (source != null && source.length > 0) {
            boolean flag = true;
            while (flag) {
                flag = false;
                for (int i = 0; i < source.length - 1; i++) {
                    if (source[i] > source[i + 1]) {
                        int temp = source[i];
                        source[i] = source[i + 1];
                        source[i + 1] = temp;
                        flag = true;
                    }
                }
            }
        }
        return source;
    }
public static int[] bubbleSort2(int[] source) {
        if (null != source && source.length > 0) {
            boolean flag = false;
            while (!flag) {
                for (int i = 0; i < source.length - 1; i++) {
                    if (source[i] > source[i + 1]) {
                        int temp = source[i];
                        source[i] = source[i + 1];
                        source[i + 1] = temp;
                        break;
                    } else if (i == source.length - 2) {
                        flag = true;
                    }
                }
            }
        }
        return source;
    }
public static void main(String[] args) {
        FileInputStream fr = null;
        FileOutputStream fw = null;
        BufferedInputStream br = null;
        BufferedOutputStream bw = null;
        try {
            fr = new FileInputStream("D:/5.xls");
            fw = new FileOutputStream("c:/Dxw.java");
            br = new BufferedInputStream(fr);
            bw = new BufferedOutputStream(fw);
            int read = br.read();
            while (read != -1) {
                bw.write(read);
                read = br.read();
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (br != null) {
                try {
                    br.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (bw != null) {
                try {
                    bw.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
protected URLConnection openConnection(URL url) throws IOException {
        URLStreamHandler handler = factory.findAuthorizedURLStreamHandler(protocol);
        if (handler != null) {
            try {
                return (URLConnection) openConnectionMethod.invoke(handler, new Object[] { url });
            } catch (Exception e) {
                factory.adaptor.getFrameworkLog().log(new FrameworkLogEntry(MultiplexingURLStreamHandler.class.getName(), "openConnection", FrameworkLogEntry.ERROR, e, null));
                throw new RuntimeException(e.getMessage());
            }
        }
        throw new MalformedURLException();
    }
private Datastream addManagedDatastreamVersion(Entry entry) throws StreamIOException, ObjectIntegrityException {
        Datastream ds = new DatastreamManagedContent();
        setDSCommonProperties(ds, entry);
        ds.DSLocationType = "INTERNAL_ID";
        ds.DSMIME = getDSMimeType(entry);
        IRI contentLocation = entry.getContentSrc();
        if (contentLocation != null) {
            if (m_obj.isNew()) {
                ValidationUtility.validateURL(contentLocation.toString(), ds.DSControlGrp);
            }
            if (m_format.equals(ATOM_ZIP1_1)) {
                if (!contentLocation.isAbsolute() && !contentLocation.isPathAbsolute()) {
                    File f = getContentSrcAsFile(contentLocation);
                    contentLocation = new IRI(DatastreamManagedContent.TEMP_SCHEME + f.getAbsolutePath());
                }
            }
            ds.DSLocation = contentLocation.toString();
            ds.DSLocation = (DOTranslationUtility.normalizeDSLocationURLs(m_obj.getPid(), ds, m_transContext)).DSLocation;
            return ds;
        }
        try {
            File temp = File.createTempFile("binary-datastream", null);
            OutputStream out = new FileOutputStream(temp);
            if (MimeTypeHelper.isText(ds.DSMIME) || MimeTypeHelper.isXml(ds.DSMIME)) {
                IOUtils.copy(new StringReader(entry.getContent()), out, m_encoding);
            } else {
                IOUtils.copy(entry.getContentStream(), out);
            }
            ds.DSLocation = DatastreamManagedContent.TEMP_SCHEME + temp.getAbsolutePath();
        } catch (IOException e) {
            throw new StreamIOException(e.getMessage(), e);
        }
        return ds;
    }
private String getCoded(String pass) {
        String passSecret = "";
        try {
            MessageDigest m = MessageDigest.getInstance("MD5");
            m.update(pass.getBytes("UTF8"));
            byte s[] = m.digest();
            for (int i = 0; i < s.length; i++) {
                passSecret += Integer.toHexString((0x000000ff & s[i]) | 0xffffff00).substring(6);
            }
        } catch (NoSuchAlgorithmException e1) {
            e1.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
        return passSecret;
    }
public static String encryptPassword(String password) throws PasswordException {
        String hash = null;
        if (password != null && !password.equals("")) {
            try {
                MessageDigest md = MessageDigest.getInstance("SHA");
                md.update(password.getBytes("UTF-8"));
                byte raw[] = md.digest();
                hash = (new BASE64Encoder()).encode(raw);
            } catch (NoSuchAlgorithmException nsae) {
                throw new PasswordException(PasswordException.SYSTEM_ERROR);
            } catch (UnsupportedEncodingException uee) {
                throw new PasswordException(PasswordException.SYSTEM_ERROR);
            }
        }
        return hash;
    }
@Test
    public void usingStream() throws IOException, NameNotFoundException {
        URL url = new URL("ftp://ftp.ebi.ac.uk/pub/databases/interpro/entry.list");
        InterproNameHandler handler = new InterproNameHandler(url.openStream());
        String interproName = handler.getNameById("IPR008255");
        assertNotNull(interproName);
        assertEquals("Pyridine nucleotide-disulphide oxidoreductase, class-II, active site", interproName);
        assertEquals(null, handler.getNameById("Active_site"));
    }
public boolean copyStoredTileTo(File targetFileName, int x, int y, int zoom, MapSource tileSource) throws IOException {
        File sourceFile = getTileFile(x, y, zoom, tileSource);
        if (!sourceFile.exists()) return false;
        FileInputStream fis = null;
        FileOutputStream fos = null;
        long sourceBytes = 0;
        long writtenBytes = 0;
        try {
            fis = new FileInputStream(sourceFile);
            fos = new FileOutputStream(targetFileName);
            FileChannel source = fis.getChannel();
            FileChannel destination = fos.getChannel();
            sourceBytes = source.size();
            writtenBytes = destination.transferFrom(source, 0, sourceBytes);
        } finally {
            Utilities.closeStream(fis);
            Utilities.closeStream(fos);
        }
        if (writtenBytes != sourceBytes) throw new IOException("Target file's size is not equal to the source file's size!");
        return true;
    }
public StringBuffer get(URL url) throws IOException {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(url.openStream()));
        StringBuffer page = new StringBuffer();
        String line = null;
        while ((line = bufferedReader.readLine()) != null) {
            String utf = new String(line.getBytes("UTF-8"), "UTF-8");
            page.append(utf);
        }
        bufferedReader.close();
        return page;
    }
@Override
    protected void setUp() throws Exception {
        this.logger = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
        File repoFolder = new File("target/repository");
        removeRepository(repoFolder);
        InputStream repoConfigIn = getClass().getResourceAsStream(REPO_CONFIG_FILE);
        File tempRepoConfigFile = File.createTempFile("repository", "xml");
        tempRepoConfigFile.deleteOnExit();
        OutputStream tempRepoConfigOut = new FileOutputStream(tempRepoConfigFile);
        try {
            IOUtils.copy(repoConfigIn, tempRepoConfigOut);
        } finally {
            repoConfigIn.close();
            tempRepoConfigOut.close();
        }
        Repository repo = new TransientRepository(tempRepoConfigFile.getAbsolutePath(), "target/repository");
        ServerAdapterFactory factory = new ServerAdapterFactory();
        RemoteRepository remoteRepo = factory.getRemoteRepository(repo);
        reg = LocateRegistry.createRegistry(Registry.REGISTRY_PORT);
        reg.rebind(REMOTE_REPO_NAME, remoteRepo);
        session = repo.login(new SimpleCredentials(LOGIN, PWD.toCharArray()), WORKSPACE);
        InputStream nodeTypeDefIn = getClass().getResourceAsStream(MQ_JCR_XML_NODETYPES_FILE);
        JackrabbitInitializerHelper.setupRepository(session, new InputStreamReader(nodeTypeDefIn), "");
    }
public ScoreModel(URL url) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
        String line;
        list = new ArrayList<ScoreModelItem>();
        map = new HashMap<String, ScoreModelItem>();
        line = in.readLine();
        int n = 1;
        String[] rowAttrib;
        ScoreModelItem item;
        while ((line = in.readLine()) != null) {
            rowAttrib = line.split(";");
            item = new ScoreModelItem(n, Double.valueOf(rowAttrib[3]), Double.valueOf(rowAttrib[4]), Double.valueOf(rowAttrib[2]), Double.valueOf(rowAttrib[5]), rowAttrib[1]);
            list.add(item);
            map.put(item.getHash(), item);
            n++;
        }
        in.close();
    }
private void unzip(File filename) throws ZipException, IOException {
        ZipInputStream in = new ZipInputStream(new BufferedInputStream(new FileInputStream(filename)));
        ZipEntry entry = null;
        boolean first_entry = true;
        while ((entry = in.getNextEntry()) != null) {
            if (first_entry) {
                if (!entry.isDirectory()) {
                    File subdir = new File(dir + File.separator + filename.getName().substring(0, filename.getName().length() - SUFFIX_ZIP.length()));
                    if (!subdir.exists()) {
                        subdir.mkdir();
                        dir = subdir;
                    }
                }
                first_entry = false;
            }
            if (entry.isDirectory()) {
                FileUtils.forceMkdir(new File(dir + File.separator + entry.getName()));
            } else {
                File outfile = new File(dir + File.separator + entry.getName());
                File outdir = new File(outfile.getAbsolutePath().substring(0, outfile.getAbsolutePath().length() - outfile.getName().length()));
                if (!outdir.exists()) FileUtils.forceMkdir(outdir);
                FileOutputStream fo = new FileOutputStream(outfile);
                BufferedOutputStream bos = new BufferedOutputStream(fo, BUFFER);
                int read;
                byte data[] = new byte[BUFFER];
                while ((read = in.read(data, 0, BUFFER)) != -1) {
                    read_position++;
                    bos.write(data, 0, read);
                }
                bos.flush();
                bos.close();
            }
        }
        in.close();
    }
public static List<PluginInfo> getPluginInfos(String urlRepo) throws MalformedURLException, IOException {
        XStream xStream = new XStream();
        xStream.alias("plugin", PluginInfo.class);
        xStream.alias("plugins", List.class);
        List<PluginInfo> infos = null;
        URL url;
        BufferedReader in = null;
        StringBuilder buffer = new StringBuilder();
        try {
            url = new URL(urlRepo);
            in = new BufferedReader(new InputStreamReader(url.openStream()));
            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                buffer.append(inputLine);
            }
        } finally {
            try {
                if (in != null) {
                    in.close();
                }
            } catch (IOException ex) {
                Logger.getLogger(RemotePluginsManager.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        infos = (List<PluginInfo>) xStream.fromXML(buffer.toString());
        return infos;
    }
public ClientDTO changePassword(String pMail, String pMdp) {
        Client vClientBean = null;
        ClientDTO vClientDTO = null;
        vClientBean = mClientDao.getClient(pMail);
        if (vClientBean != null) {
            MessageDigest vMd5Instance;
            try {
                vMd5Instance = MessageDigest.getInstance("MD5");
                vMd5Instance.reset();
                vMd5Instance.update(pMdp.getBytes());
                byte[] vDigest = vMd5Instance.digest();
                BigInteger vBigInt = new BigInteger(1, vDigest);
                String vHashPassword = vBigInt.toString(16);
                vClientBean.setMdp(vHashPassword);
                vClientDTO = BeanToDTO.getInstance().createClientDTO(vClientBean);
            } catch (NoSuchAlgorithmException e) {
                e.printStackTrace();
            }
        }
        return vClientDTO;
    }
private static FileChannel getFileChannel(File file, boolean isOut, boolean append) throws OpenR66ProtocolSystemException {
        FileChannel fileChannel = null;
        try {
            if (isOut) {
                FileOutputStream fileOutputStream = new FileOutputStream(file.getPath(), append);
                fileChannel = fileOutputStream.getChannel();
                if (append) {
                    try {
                        fileChannel.position(file.length());
                    } catch (IOException e) {
                    }
                }
            } else {
                if (!file.exists()) {
                    throw new OpenR66ProtocolSystemException("File does not exist");
                }
                FileInputStream fileInputStream = new FileInputStream(file.getPath());
                fileChannel = fileInputStream.getChannel();
            }
        } catch (FileNotFoundException e) {
            throw new OpenR66ProtocolSystemException("File not found", e);
        }
        return fileChannel;
    }
public static synchronized String getMD5_Base64(String input) {
        MessageDigest msgDigest = null;
        try {
            msgDigest = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            throw new IllegalStateException("System doesn't support MD5 algorithm.");
        }
        try {
            msgDigest.update(input.getBytes("UTF-8"));
        } catch (java.io.UnsupportedEncodingException ex) {
            throw new IllegalStateException("System doesn't support your  EncodingException.");
        }
        byte[] rawData = msgDigest.digest();
        byte[] encoded = Base64.encodeBase64(rawData);
        String retValue = new String(encoded);
        return retValue;
    }