semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public static void main(final String[] args) throws RecognitionException, TokenStreamException, IOException, IllegalOptionValueException, UnknownOptionException {
        try {
            CmdLineParser cmdLineParser = new CmdLineParser();
            Option formatOption = cmdLineParser.addStringOption('f', "format");
            Option encodingOption = cmdLineParser.addStringOption('c', "charset");
            cmdLineParser.parse(args);
            String format = (String) cmdLineParser.getOptionValue(formatOption);
            String encoding = (String) cmdLineParser.getOptionValue(encodingOption);
            if (encoding == null || encoding.trim().equals("")) {
                encoding = "utf-8";
                System.out.println("Defaulting to output charset utf-8 as argument -c is missing or not valid.");
            }
            String[] remainingArgs = cmdLineParser.getRemainingArgs();
            if (remainingArgs.length != 2) {
                printUsage("Input and output file are not specified correctly. ");
            }
            File inputFile = new File(remainingArgs[0]);
            if (!inputFile.exists()) {
                printUsage("Input file " + remainingArgs[0] + " does not exist. ");
            }
            File outputFile = new File(remainingArgs[1]);
            if (!outputFile.exists()) {
                outputFile.createNewFile();
            }
            if (format == null || format.trim().equals("")) {
                format = (String) FileUtil.cutExtension(outputFile.getName()).getValue();
            }
            if ("tex".equals(format)) {
                Reader reader = new LatexEncoderReader(new FileReader(inputFile));
                OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(outputFile), encoding);
                char[] buffer = new char[1024];
                int read;
                do {
                    read = reader.read(buffer);
                    if (read > 0) {
                        out.write(buffer, 0, read);
                    }
                } while (read != -1);
                out.flush();
                out.close();
            } else {
                printUsage("Format not specified via argument -f. Also guessing for the extension of output file " + outputFile.getName() + " failed");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            printUsage(ex.getMessage());
        }
    }
private SystemProperties() {
        Properties p = new Properties();
        ClassLoader classLoader = getClass().getClassLoader();
        try {
            URL url = classLoader.getResource("system.properties");
            if (url != null) {
                InputStream is = url.openStream();
                p.load(is);
                is.close();
                System.out.println("Loading " + url);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        try {
            URL url = classLoader.getResource("system-ext.properties");
            if (url != null) {
                InputStream is = url.openStream();
                p.load(is);
                is.close();
                System.out.println("Loading " + url);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        boolean systemPropertiesLoad = GetterUtil.get(System.getProperty(SYSTEM_PROPERTIES_LOAD), true);
        boolean systemPropertiesFinal = GetterUtil.get(System.getProperty(SYSTEM_PROPERTIES_FINAL), true);
        if (systemPropertiesLoad) {
            Enumeration enu = p.propertyNames();
            while (enu.hasMoreElements()) {
                String key = (String) enu.nextElement();
                if (systemPropertiesFinal || Validator.isNull(System.getProperty(key))) {
                    System.setProperty(key, (String) p.get(key));
                }
            }
        }
        PropertiesUtil.fromProperties(p, _props);
    }
public static String encryptPassword(String password) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        final MessageDigest digester = MessageDigest.getInstance("sha-256");
        digester.reset();
        digester.update("Carmen Sandiago".getBytes());
        return asHex(digester.digest(password.getBytes("UTF-8")));
    }
private static String func(String sf) {
        int total = 0, temp;
        String fnctn[] = { "sin", "cos", "tan", "log", "ln", "sqrt", "!" }, temp2 = "";
        int pos[] = new int[7];
        for (int n = 0; n < fnctn.length; n++) {
            pos[n] = sf.lastIndexOf(fnctn[n]);
        }
        for (int m = 0; m < fnctn.length; m++) {
            total += pos[m];
        }
        if (total == -7) {
            return sf;
        }
        for (int i = pos.length; i > 1; i--) {
            for (int j = 0; j < i - 1; j++) {
                if (pos[j] < pos[j + 1]) {
                    temp = pos[j];
                    pos[j] = pos[j + 1];
                    pos[j + 1] = temp;
                    temp2 = fnctn[j];
                    fnctn[j] = fnctn[j + 1];
                    fnctn[j + 1] = temp2;
                }
            }
        }
        if (fnctn[0].equals("sin")) {
            if ((pos[0] == 0 || sf.charAt(pos[0] - 1) != 'a')) {
                return func(Functions.sine(sf, pos[0], false));
            } else {
                return func(Functions.asin(sf, pos[0], false));
            }
        } else if (fnctn[0].equals("cos")) {
            if ((pos[0] == 0 || sf.charAt(pos[0] - 1) != 'a')) {
                return func(Functions.cosine(sf, pos[0], false));
            } else {
                return func(Functions.acos(sf, pos[0], false));
            }
        } else if (fnctn[0].equals("tan")) {
            if ((pos[0] == 0 || sf.charAt(pos[0] - 1) != 'a')) {
                return func(Functions.tangent(sf, pos[0], false));
            } else {
                return func(Functions.atan(sf, pos[0], false));
            }
        } else if (fnctn[0].equals("log")) {
            return func(Functions.logarithm(sf, pos[0]));
        } else if (fnctn[0].equals("ln")) {
            return func(Functions.lnat(sf, pos[0]));
        } else if (fnctn[0].equals("sqrt")) {
            return func(Functions.sqroot(sf, pos[0]));
        } else {
            return func(Functions.factorial(sf, pos[0]));
        }
    }
@SuppressWarnings("null")
    public static void copyFile(File src, File dst) throws IOException {
        if (!dst.getParentFile().exists()) {
            dst.getParentFile().mkdirs();
        }
        dst.createNewFile();
        FileChannel srcC = null;
        FileChannel dstC = null;
        try {
            srcC = new FileInputStream(src).getChannel();
            dstC = new FileOutputStream(dst).getChannel();
            dstC.transferFrom(srcC, 0, srcC.size());
        } finally {
            try {
                if (dst != null) {
                    dstC.close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
            try {
                if (src != null) {
                    srcC.close();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
public static void unzip(File sourceZipFile, File unzipDestinationDirectory, FileFilter filter) throws IOException {
        unzipDestinationDirectory.mkdirs();
        if (!unzipDestinationDirectory.exists()) {
            throw new IOException("Unable to create destination directory: " + unzipDestinationDirectory);
        }
        ZipFile zipFile;
        zipFile = new ZipFile(sourceZipFile, ZipFile.OPEN_READ);
        Enumeration<? extends ZipEntry> zipFileEntries = zipFile.entries();
        while (zipFileEntries.hasMoreElements()) {
            ZipEntry entry = (ZipEntry) zipFileEntries.nextElement();
            if (!entry.isDirectory()) {
                String currentEntry = entry.getName();
                File destFile = new File(unzipDestinationDirectory, currentEntry);
                if (filter == null || filter.accept(destFile)) {
                    File destinationParent = destFile.getParentFile();
                    destinationParent.mkdirs();
                    BufferedInputStream is = new BufferedInputStream(zipFile.getInputStream(entry));
                    FileOutputStream fos = new FileOutputStream(destFile);
                    IOUtils.copyLarge(is, fos);
                    fos.flush();
                    IOUtils.closeQuietly(fos);
                }
            }
        }
        zipFile.close();
    }
public static void zip(File srcDir, File destFile, FileFilter filter) throws IOException {
        ZipOutputStream out = null;
        try {
            out = new ZipOutputStream(new FileOutputStream(destFile));
            Collection<File> files = FileUtils.listFiles(srcDir, TrueFileFilter.TRUE, TrueFileFilter.TRUE);
            for (File f : files) {
                if (filter == null || filter.accept(f)) {
                    FileInputStream in = FileUtils.openInputStream(f);
                    out.putNextEntry(new ZipEntry(Util.relativePath(srcDir, f).replace('\\', '/')));
                    IOUtils.copyLarge(in, out);
                    out.closeEntry();
                    IOUtils.closeQuietly(in);
                }
            }
            IOUtils.closeQuietly(out);
        } catch (Throwable t) {
            throw new IOException("Failed to create zip file", t);
        } finally {
            if (out != null) {
                out.flush();
                IOUtils.closeQuietly(out);
            }
        }
    }
public Vector split() {
        File nextFile = new File(filename);
        long fileSize = nextFile.length();
        long parts = fileSize / splitSize;
        Vector vec = new Vector(new Long(parts).intValue());
        if (debug) {
            System.out.println("File: " + nextFile.getName() + "\nfileSize: " + fileSize + "\nsplitSize: " + splitSize + "\nparts: " + parts);
        }
        if (fileSize % splitSize > 0) {
            parts++;
        }
        try {
            FileInputStream fis = new FileInputStream(nextFile);
            DataInputStream dis = new DataInputStream(fis);
            long bytesRead = 0;
            File destinationDirectory = new File(nextFile.getParent());
            if (!destinationDirectory.exists()) {
                destinationDirectory.mkdir();
            }
            for (long k = 0; k < parts; k++) {
                if (debug) {
                    System.out.println("Splitting parts: " + nextFile.getName() + " into part " + k);
                }
                String filePartName = nextFile.getName();
                filePartName = filePartName + "." + String.valueOf(k);
                File outputFile = new File(destinationDirectory, filePartName);
                FileOutputStream fos = new FileOutputStream(outputFile);
                DataOutputStream dos = new DataOutputStream(fos);
                long bytesWritten = 0;
                while ((bytesWritten < splitSize) && (bytesRead < fileSize)) {
                    dos.writeByte(dis.readByte());
                    bytesRead++;
                    bytesWritten++;
                }
                dos.close();
                vec.addElement(outputFile.getAbsolutePath());
                if (debug) {
                    System.out.println("Wrote " + bytesWritten + " bytes." + outputFile.getName() + " created.");
                }
            }
        } catch (FileNotFoundException fnfe) {
            System.err.println("FileNotFoundException: " + fnfe.getMessage());
            vec = null;
        } catch (IOException ioe) {
            System.err.println("IOException: " + ioe.getMessage());
            vec = null;
        }
        return vec;
    }
public static String encipherAMessage(String message) {
        try {
            MessageDigest sha1 = MessageDigest.getInstance(java.util.ResourceBundle.getBundle("com/jjcp/resources/Strings").getString("SHA1"));
            sha1.update(message.getBytes(java.util.ResourceBundle.getBundle("com/jjcp/resources/Strings").getString("UTF-16LE")));
            byte[] digest = sha1.digest();
            BASE64Encoder base64encoder = new BASE64Encoder();
            String cipherTextB64 = base64encoder.encode(digest);
            return cipherTextB64;
        } catch (UnsupportedEncodingException ex) {
            Logger.getLogger(SelectorView.class.getName()).log(Level.SEVERE, null, ex);
        } catch (NoSuchAlgorithmException ex) {
            Logger.getLogger(SelectorView.class.getName()).log(Level.SEVERE, null, ex);
        }
        return "";
    }
private void channelCopy(File source, File dest) throws IOException {
        FileChannel srcChannel = new FileInputStream(source).getChannel();
        FileChannel dstChannel = new FileOutputStream(dest).getChannel();
        try {
            dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
        } finally {
            srcChannel.close();
            dstChannel.close();
        }
    }
public AssemblyConfig load() {
        AssemblyConfig assembly = null;
        Digester digester = createParser();
        try {
            if (inputStream != null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("XML config loader is parsing an inputstream:" + inputStream);
                }
                assembly = (AssemblyConfig) digester.parse(inputStream);
            } else if (file != null) {
                if (logger.isDebugEnabled()) {
                    logger.debug("XML config loader is parsing a file:" + file);
                }
                assembly = (AssemblyConfig) digester.parse(file);
            } else {
                if (logger.isDebugEnabled()) {
                    logger.debug("XML config loader is parsing a URI:" + uri);
                }
                URL url = new URL(uri);
                inputStream = url.openStream();
                assembly = (AssemblyConfig) digester.parse(inputStream);
            }
            if (assembly != null) {
                logger.debug("Services from XML configuration are: ");
                logger.debug(assembly.toString());
            } else {
                throw new AssemblyConfigException("Unable to parse the XML assembly configuration. " + "HINT: Please check the schema/grammar of the supplied " + "XML document and verify the XML namespace is correct.");
            }
        } catch (IOException ioe) {
            throw new AssemblyConfigException("I/O failure, unable to process configuration", ioe);
        } catch (SAXException sxe) {
            throw new AssemblyConfigException("XML Reader failure, unable to process configuration", sxe);
        }
        return assembly;
    }
private void trainSRLParser(byte flag, JarArchiveOutputStream zout) throws Exception {
        AbstractSRLParser labeler = null;
        AbstractDecoder[] decoder = null;
        if (flag == SRLParser.FLAG_TRAIN_LEXICON) {
            System.out.println("\n* Save lexica");
            labeler = new SRLParser(flag, s_featureXml);
        } else if (flag == SRLParser.FLAG_TRAIN_INSTANCE) {
            System.out.println("\n* Print training instances");
            System.out.println("- loading lexica");
            labeler = new SRLParser(flag, t_xml, s_lexiconFiles);
        } else if (flag == SRLParser.FLAG_TRAIN_BOOST) {
            System.out.println("\n* Train boost");
            decoder = new AbstractDecoder[m_model.length];
            for (int i = 0; i < decoder.length; i++) decoder[i] = new OneVsAllDecoder((OneVsAllModel) m_model[i]);
            labeler = new SRLParser(flag, t_xml, t_map, decoder);
        }
        AbstractReader<DepNode, DepTree> reader = new SRLReader(s_trainFile, true);
        DepTree tree;
        int n;
        labeler.setLanguage(s_language);
        reader.setLanguage(s_language);
        for (n = 0; (tree = reader.nextTree()) != null; n++) {
            labeler.parse(tree);
            if (n % 1000 == 0) System.out.printf("\r- parsing: %dK", n / 1000);
        }
        System.out.println("\r- labeling: " + n);
        if (flag == SRLParser.FLAG_TRAIN_LEXICON) {
            System.out.println("- labeling");
            labeler.saveTags(s_lexiconFiles);
            t_xml = labeler.getSRLFtrXml();
        } else if (flag == SRLParser.FLAG_TRAIN_INSTANCE || flag == SRLParser.FLAG_TRAIN_BOOST) {
            a_yx = labeler.a_trans;
            zout.putArchiveEntry(new JarArchiveEntry(ENTRY_FEATURE));
            IOUtils.copy(new FileInputStream(s_featureXml), zout);
            zout.closeArchiveEntry();
            for (String lexicaFile : s_lexiconFiles) {
                zout.putArchiveEntry(new JarArchiveEntry(lexicaFile));
                IOUtils.copy(new FileInputStream(lexicaFile), zout);
                zout.closeArchiveEntry();
            }
            if (flag == SRLParser.FLAG_TRAIN_INSTANCE) t_map = labeler.getSRLFtrMap();
        }
    }
public void visit(BosMember member) throws BosException {
        String relative = AddressingUtil.getRelativePath(member.getDataSourceUri(), baseUri);
        URL resultUrl;
        try {
            resultUrl = new URL(outputUrl, relative);
            File resultFile = new File(resultUrl.toURI());
            resultFile.getParentFile().mkdirs();
            log.info("Creating result file \"" + resultFile.getAbsolutePath() + "\"...");
            IOUtils.copy(member.getInputStream(), new FileOutputStream(resultFile));
        } catch (Exception e) {
            throw new BosException(e);
        }
    }
public boolean setCliente(int IDcliente, String nombre, String paterno, String materno, String ocupacion, String rfc) {
        boolean inserto = false;
        try {
            stm = conexion.prepareStatement("insert into clientes values( '" + IDcliente + "' , '" + nombre.toUpperCase() + "' , '" + paterno.toUpperCase() + "' , '" + materno.toUpperCase() + "' , '" + ocupacion.toUpperCase() + "' , '" + rfc + "' )");
            stm.executeUpdate();
            conexion.commit();
            inserto = true;
        } catch (SQLException e) {
            System.out.println("error al insertar registro en la tabla clientes general  " + e.getMessage());
            try {
                conexion.rollback();
            } catch (SQLException ee) {
                System.out.println(ee.getMessage());
            }
            return inserto = false;
        }
        return inserto;
    }
public boolean setUpdateCliente(int IDcliente, String nombre, String paterno, String materno, String ocupacion, String rfc) {
        boolean update = false;
        try {
            stm = conexion.prepareStatement("update clientes set nombre='" + nombre.toUpperCase().trim() + "' , paterno='" + paterno.toUpperCase().trim() + "' ," + "materno='" + materno.toUpperCase().trim() + "',ocupacion='" + ocupacion.toUpperCase().trim() + "',rfc='" + rfc.trim() + "' where IDcliente ='" + IDcliente + "' ");
            stm.executeUpdate();
            conexion.commit();
            update = true;
        } catch (SQLException e) {
            System.out.println("error al actualizar registro en la tabla clientes  " + e.getMessage());
            try {
                conexion.rollback();
            } catch (SQLException ee) {
                System.out.println(ee.getMessage());
            }
            return update = false;
        }
        return update;
    }
public boolean setDeleteCliente(int IDcliente) {
        boolean delete = false;
        try {
            stm = conexion.prepareStatement("delete clientes where IDcliente='" + IDcliente + "'");
            stm.executeUpdate();
            conexion.commit();
            delete = true;
        } catch (SQLException e) {
            System.out.println("Error en la eliminacion del registro en tabla clientes " + e.getMessage());
            try {
                conexion.rollback();
            } catch (SQLException ee) {
                System.out.println(ee.getMessage());
            }
            return delete = false;
        }
        return delete;
    }
public static String sendGetRequest(String endpoint, String requestParameters) {
        String result = null;
        if (endpoint.startsWith("http://")) {
            try {
                System.setProperty("java.net.useSystemProxies", "true");
                String urlStr = endpoint;
                if (requestParameters != null && requestParameters.length() > 0) {
                    urlStr += "?" + requestParameters;
                }
                URL url = new URL(urlStr);
                URLConnection conn = url.openConnection();
                BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                StringBuffer sb = new StringBuffer();
                String line;
                while ((line = rd.readLine()) != null) {
                    sb.append(line + "\n");
                }
                rd.close();
                result = sb.toString();
            } catch (Exception e) {
                DebuggerQueue.addDebug(HTTPClient.class.getName(), Level.ERROR, "Error during download url %s error: %s", endpoint, e.getMessage());
            }
        }
        return result;
    }
public static void postData(Reader data, URL endpoint, Writer output) throws Exception {
        HttpURLConnection urlc = null;
        try {
            urlc = (HttpURLConnection) endpoint.openConnection();
            try {
                urlc.setRequestMethod("POST");
            } catch (ProtocolException e) {
                throw new Exception("Shouldn't happen: HttpURLConnection doesn't support POST??", e);
            }
            urlc.setDoOutput(true);
            urlc.setDoInput(true);
            urlc.setUseCaches(false);
            urlc.setAllowUserInteraction(false);
            urlc.setRequestProperty("Content-type", "text/xml; charset=" + "UTF-8");
            OutputStream out = urlc.getOutputStream();
            try {
                Writer writer = new OutputStreamWriter(out, "UTF-8");
                pipe(data, writer);
                writer.close();
            } catch (IOException e) {
                throw new Exception("IOException while posting data", e);
            } finally {
                if (out != null) out.close();
            }
            InputStream in = urlc.getInputStream();
            try {
                Reader reader = new InputStreamReader(in);
                pipe(reader, output);
                reader.close();
            } catch (IOException e) {
                throw new Exception("IOException while reading response", e);
            } finally {
                if (in != null) in.close();
            }
        } catch (IOException e) {
            throw new Exception("Connection error (is server running at " + endpoint + " ?): " + e);
        } finally {
            if (urlc != null) urlc.disconnect();
        }
    }
public static void downloadFromUrl(URL url, String localFilename, String userAgent) throws IOException {
        InputStream is = null;
        FileOutputStream fos = null;
        System.setProperty("java.net.useSystemProxies", "true");
        try {
            URLConnection urlConn = url.openConnection();
            if (userAgent != null) {
                urlConn.setRequestProperty("User-Agent", userAgent);
            }
            is = urlConn.getInputStream();
            fos = new FileOutputStream(localFilename);
            byte[] buffer = new byte[4096];
            int len;
            while ((len = is.read(buffer)) > 0) {
                fos.write(buffer, 0, len);
            }
        } finally {
            try {
                if (is != null) {
                    is.close();
                }
            } finally {
                if (fos != null) {
                    fos.close();
                }
            }
        }
    }
public static String getFileText(URL _url) {
        try {
            InputStream input = _url.openStream();
            String content = IOUtils.toString(input);
            IOUtils.closeQuietly(input);
            return content;
        } catch (Exception err) {
            LOG.error(_url.toString(), err);
            return "";
        }
    }