semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
private void DrawModel(Graphics offg, int obj_num, boolean object, float h, float s, int vt_num, int fc_num) {
        int px[] = new int[3];
        int py[] = new int[3];
        int count = 0;
        int tmp[] = new int[fc_num];
        double tmp_depth[] = new double[fc_num];
        rotate(vt_num);
        offg.setColor(Color.black);
        for (int i = 0; i < fc_num; i++) {
            double a1 = fc[i].vt1.x - fc[i].vt0.x;
            double a2 = fc[i].vt1.y - fc[i].vt0.y;
            double a3 = fc[i].vt1.z - fc[i].vt0.z;
            double b1 = fc[i].vt2.x - fc[i].vt1.x;
            double b2 = fc[i].vt2.y - fc[i].vt1.y;
            double b3 = fc[i].vt2.z - fc[i].vt1.z;
            fc[i].nx = a2 * b3 - a3 * b2;
            fc[i].ny = a3 * b1 - a1 * b3;
            fc[i].nz = a1 * b2 - a2 * b1;
            if (fc[i].nz < 0) {
                fc[i].nx = a2 * b3 - a3 * b2;
                fc[i].ny = a3 * b1 - a1 * b3;
                tmp[count] = i;
                tmp_depth[count] = fc[i].getDepth();
                count++;
            }
        }
        int lim = count - 1;
        do {
            int m = 0;
            for (int n = 0; n <= lim - 1; n++) {
                if (tmp_depth[n] < tmp_depth[n + 1]) {
                    double t = tmp_depth[n];
                    tmp_depth[n] = tmp_depth[n + 1];
                    tmp_depth[n + 1] = t;
                    int ti = tmp[n];
                    tmp[n] = tmp[n + 1];
                    tmp[n + 1] = ti;
                    m = n;
                }
            }
            lim = m;
        } while (lim != 0);
        for (int m = 0; m < count; m++) {
            int i = tmp[m];
            double l = Math.sqrt(fc[i].nx * fc[i].nx + fc[i].ny * fc[i].ny + fc[i].nz * fc[i].nz);
            test(offg, i, l, h, s);
            px[0] = (int) (fc[i].vt0.x * m_Scale + centerp.x);
            py[0] = (int) (-fc[i].vt0.y * m_Scale + centerp.y);
            px[1] = (int) (fc[i].vt1.x * m_Scale + centerp.x);
            py[1] = (int) (-fc[i].vt1.y * m_Scale + centerp.y);
            px[2] = (int) (fc[i].vt2.x * m_Scale + centerp.x);
            py[2] = (int) (-fc[i].vt2.y * m_Scale + centerp.y);
            offg.fillPolygon(px, py, 3);
        }
        if (labelFlag && object) {
            offg.setFont(Fonts.FONT_REAL);
            offg.drawString(d_con.getPointerData().getRealObjName(obj_num), (int) ((fc[0].vt0.x + 10) * m_Scale + centerp.x), (int) (-(fc[0].vt0.y + 10) * m_Scale + centerp.y));
        }
    }
public final Matrix2D<E> read(final URL url) throws IOException {
        if (url == null) {
            throw new IllegalArgumentException("url must not be null");
        }
        InputStream inputStream = null;
        try {
            inputStream = url.openStream();
            return read(inputStream);
        } catch (IOException e) {
            throw e;
        } finally {
            MatrixIOUtils.closeQuietly(inputStream);
        }
    }
private static String genRandomGUID(boolean secure) {
        String valueBeforeMD5 = "";
        String valueAfterMD5 = "";
        MessageDigest md5 = null;
        StringBuffer sbValueBeforeMD5 = new StringBuffer();
        try {
            md5 = MessageDigest.getInstance("MD5");
        } catch (NoSuchAlgorithmException e) {
            System.out.println("Error: " + e);
            return valueBeforeMD5;
        }
        long time = System.currentTimeMillis();
        long rand = 0;
        if (secure) {
            rand = mySecureRand.nextLong();
        } else {
            rand = myRand.nextLong();
        }
        sbValueBeforeMD5.append(s_id);
        sbValueBeforeMD5.append(":");
        sbValueBeforeMD5.append(Long.toString(time));
        sbValueBeforeMD5.append(":");
        sbValueBeforeMD5.append(Long.toString(rand));
        valueBeforeMD5 = sbValueBeforeMD5.toString();
        md5.update(valueBeforeMD5.getBytes());
        byte[] array = md5.digest();
        String strTemp = "";
        for (int i = 0; i < array.length; i++) {
            strTemp = (Integer.toHexString(array[i] & 0XFF));
            if (strTemp.length() == 1) {
                valueAfterMD5 = valueAfterMD5 + "0" + strTemp;
            } else {
                valueAfterMD5 = valueAfterMD5 + strTemp;
            }
        }
        return valueAfterMD5.toUpperCase();
    }
public static String encrypt(String plaintext) throws Exception {
        String algorithm = XML.get("security.algorithm");
        if (algorithm == null) algorithm = "SHA-1";
        MessageDigest md = MessageDigest.getInstance(algorithm);
        md.update(plaintext.getBytes("UTF-8"));
        return new BASE64Encoder().encode(md.digest());
    }
public PVBrowserSearchDocument(URL url, PVBrowserModel applicationModel) {
        this(applicationModel);
        if (url != null) {
            try {
                data.loadFromXML(url.openStream());
                loadOpenPVsFromData();
                setHasChanges(false);
                setSource(url);
            } catch (java.io.IOException exception) {
                System.err.println(exception);
                displayWarning("Open Failed!", exception.getMessage(), exception);
            }
        }
    }
public static void downloadFile(HttpServletResponse response, String file) throws IOException {
        response.setContentType(FileUtils.getContentType(file));
        response.setContentLength(FileUtils.getContentLength(file));
        response.setHeader("Content-type", ResponseUtils.DOWNLOAD_CONTENT_TYPE);
        response.setHeader("Content-Disposition", "attachment; filename=\"" + FileUtils.getFileName(file) + "\"");
        response.setHeader("Content-Length", Integer.toString(FileUtils.getContentLength(file)));
        InputStream input = new FileInputStream(file);
        OutputStream output = response.getOutputStream();
        IOUtils.copy(input, output, true);
    }
public static void copyFile(HttpServletResponse response, String file) throws IOException {
        response.setContentType(FileUtils.getContentType(file));
        response.setContentLength(FileUtils.getContentLength(file));
        response.setHeader("Content-Length", Integer.toString(FileUtils.getContentLength(file)));
        InputStream input = new FileInputStream(file);
        OutputStream output = response.getOutputStream();
        IOUtils.copy(input, output, true);
    }
private static byte[] get256RandomBits() throws IOException {
        URL url = null;
        try {
            url = new URL(SRV_URL);
        } catch (MalformedURLException e) {
            e.printStackTrace();
        }
        HttpsURLConnection hu = (HttpsURLConnection) url.openConnection();
        hu.setConnectTimeout(2500);
        InputStream is = hu.getInputStream();
        byte[] content = new byte[is.available()];
        is.read(content);
        is.close();
        hu.disconnect();
        byte[] randomBits = new byte[32];
        String line = new String(content);
        Matcher m = DETAIL.matcher(line);
        if (m.find()) {
            for (int i = 0; i < 32; i++) randomBits[i] = (byte) (Integer.parseInt(m.group(1).substring(i * 2, i * 2 + 2), 16) & 0xFF);
        }
        return randomBits;
    }
private File getTestFile() {
        final URL url = TestCrueLOG.class.getResource(FICHIER_TEST_XML);
        final File ctfaFile = new File(createTempDir(), "resultat.rtfa.xml");
        try {
            CtuluLibFile.copyStream(url.openStream(), new FileOutputStream(ctfaFile), true, true);
        } catch (Exception e) {
            e.printStackTrace();
            fail();
        }
        return ctfaFile;
    }
private boolean enregistreToi() {
        PrintWriter lEcrivain;
        String laDest = "./img_types/" + sonImage;
        if (!new File("./img_types").exists()) {
            new File("./img_types").mkdirs();
        }
        try {
            FileChannel leFicSource = new FileInputStream(sonFichier).getChannel();
            FileChannel leFicDest = new FileOutputStream(laDest).getChannel();
            leFicSource.transferTo(0, leFicSource.size(), leFicDest);
            leFicSource.close();
            leFicDest.close();
            lEcrivain = new PrintWriter(new FileWriter(new File("bundll/types.jay"), true));
            lEcrivain.println(sonNom);
            lEcrivain.println(sonImage);
            if (sonOptionRadio1.isSelected()) {
                lEcrivain.println("0:?");
            }
            if (sonOptionRadio2.isSelected()) {
                lEcrivain.println("1:" + JOptionPane.showInputDialog(null, "Vous avez choisis de rendre ce terrain difficile � franchir.\nVeuillez en indiquer la raison.", "Demande de pr�cision", JOptionPane.INFORMATION_MESSAGE));
            }
            if (sonOptionRadio3.isSelected()) {
                lEcrivain.println("2:?");
            }
            lEcrivain.close();
            return true;
        } catch (Exception lException) {
            return false;
        }
    }
private static MimeType getMimeType(URL url) {
        String mimeTypeString = null;
        String charsetFromWebServer = null;
        String contentType = null;
        InputStream is = null;
        MimeType mimeTypeFromWebServer = null;
        MimeType mimeTypeFromFileSuffix = null;
        MimeType mimeTypeFromMagicNumbers = null;
        String fileSufix = null;
        if (url == null) return null;
        try {
            try {
                is = url.openConnection().getInputStream();
                contentType = url.openConnection().getContentType();
            } catch (IOException e) {
            }
            if (contentType != null) {
                StringTokenizer st = new StringTokenizer(contentType, ";");
                if (st.hasMoreTokens()) mimeTypeString = st.nextToken().toLowerCase();
                if (st.hasMoreTokens()) charsetFromWebServer = st.nextToken().toLowerCase();
                if (charsetFromWebServer != null) {
                    st = new StringTokenizer(charsetFromWebServer, "=");
                    charsetFromWebServer = null;
                    if (st.hasMoreTokens()) st.nextToken();
                    if (st.hasMoreTokens()) charsetFromWebServer = st.nextToken().toUpperCase();
                }
            }
            mimeTypeFromWebServer = mimeString2mimeTypeMap.get(mimeTypeString);
            fileSufix = getFileSufix(url);
            mimeTypeFromFileSuffix = getMimeType(fileSufix);
            mimeTypeFromMagicNumbers = guessTypeUsingMagicNumbers(is, charsetFromWebServer);
        } finally {
            IOUtils.closeQuietly(is);
        }
        return decideBetweenThreeMimeTypes(mimeTypeFromWebServer, mimeTypeFromFileSuffix, mimeTypeFromMagicNumbers);
    }
public AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException {
        InputStream stream = url.openStream();
        AudioFileFormat format;
        try {
            format = getAudioFileFormat(new BufferedInputStream(stream));
        } finally {
            stream.close();
        }
        return format;
    }
public static void copy(URL url, String outPath) throws IOException {
        System.out.println("copying from: " + url + " to " + outPath);
        InputStream in = url.openStream();
        FileOutputStream fout = new FileOutputStream(outPath);
        byte[] data = new byte[8192];
        int read = -1;
        while ((read = in.read(data)) != -1) {
            fout.write(data, 0, read);
        }
        fout.close();
    }
public byte[] transfer(@Nullable final TransferListener transferListener) {
        try {
            InputStream inputStream = url.openStream();
            ByteArrayOutputStream outputStream = new ByteArrayOutputStream(inputStream.available());
            if (transferListener != null) {
                inputStream = new ObservableInputStream(inputStream, transferListener);
            }
            ByteStreams.copy(InputSuppliers.asInputSupplier(inputStream), outputStream);
            return outputStream.toByteArray();
        } catch (IOException e) {
            throw new UnhandledException(e);
        }
    }
public void removerTopicos(Topicos topicos) throws ClassNotFoundException, SQLException {
        this.criaConexao(false);
        String sql = "DELETE FROM \"Topicos\"    " + "      WHERE \"id_Topicos\" =  ?";
        PreparedStatement stmt = null;
        try {
            stmt = connection.prepareStatement(sql);
            stmt.setString(1, topicos.getIdTopicos());
            stmt.executeUpdate();
            connection.commit();
        } catch (SQLException e) {
            connection.rollback();
            throw e;
        } finally {
            try {
                stmt.close();
                this.fechaConexao();
            } catch (SQLException e) {
                throw e;
            }
        }
    }
@Override
    public boolean connect(String host, String userName, String password) throws IOException, UnknownHostException {
        try {
            if (ftpClient != null) if (ftpClient.isConnected()) ftpClient.disconnect();
            ftpClient = new FTPSClient("SSL", false);
            boolean success = false;
            ftpClient.connect(host);
            int reply = ftpClient.getReplyCode();
            if (FTPReply.isPositiveCompletion(reply)) success = ftpClient.login(userName, password);
            if (!success) ftpClient.disconnect();
            return success;
        } catch (Exception ex) {
            throw new IOException(ex.getMessage());
        }
    }
public static Document getDocument(URL url) throws Exception {
        InputStream is = null;
        try {
            is = new BufferedInputStream(url.openStream());
            return getDocumentBuilder().parse(is);
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException e) {
                }
            }
        }
    }
private static void processFile(StreamDriver driver, String sourceName) throws Exception {
        String destName = sourceName + ".xml";
        File dest = new File(destName);
        if (dest.exists()) {
            throw new IllegalArgumentException("File '" + destName + "' already exists!");
        }
        FileChannel sourceChannel = new FileInputStream(sourceName).getChannel();
        try {
            MappedByteBuffer sourceByteBuffer = sourceChannel.map(FileChannel.MapMode.READ_ONLY, 0, sourceChannel.size());
            CharsetDecoder decoder = Charset.forName("ISO-8859-15").newDecoder();
            CharBuffer sourceBuffer = decoder.decode(sourceByteBuffer);
            driver.generateXmlDocument(sourceBuffer, new FileOutputStream(dest));
        } finally {
            sourceChannel.close();
        }
    }
public static void copyFile(File from, File to) throws IOException {
        assert (from != null);
        assert (to != null);
        if (!to.exists()) {
            File parentDir = to.getParentFile();
            if (!parentDir.exists()) parentDir.mkdirs();
            to.createNewFile();
        }
        FileInputStream in = null;
        FileOutputStream out = null;
        try {
            in = new FileInputStream(from);
            try {
                out = new FileOutputStream(to);
                FileChannel ic = in.getChannel();
                try {
                    FileChannel oc = out.getChannel();
                    try {
                        oc.transferFrom(ic, 0, from.length());
                    } finally {
                        if (oc != null) {
                            oc.close();
                        }
                    }
                } finally {
                    if (ic != null) {
                        ic.close();
                    }
                }
            } finally {
                if (out != null) {
                    out.close();
                }
            }
        } finally {
            if (in != null) {
                in.close();
            }
        }
    }
protected KMLRoot parseCachedKMLFile(URL url, String linkBase, String contentType, boolean namespaceAware) throws IOException, XMLStreamException {
        KMLDoc kmlDoc;
        InputStream refStream = url.openStream();
        if (KMLConstants.KMZ_MIME_TYPE.equals(contentType)) kmlDoc = new KMZInputStream(refStream); else kmlDoc = new KMLInputStream(refStream, WWIO.makeURI(linkBase));
        try {
            KMLRoot refRoot = new KMLRoot(kmlDoc, namespaceAware);
            refRoot.parse();
            return refRoot;
        } catch (XMLStreamException e) {
            refStream.close();
            throw e;
        }
    }
private String digest(String message) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-1");
            md.update(message.getBytes());
            BigInteger hash = new BigInteger(1, md.digest());
            String hpassword = hash.toString(16);
            return hpassword;
        } catch (Exception e) {
        }
        return null;
    }
private void fetchAlignment() throws IOException {
        String urlString = BASE_URL + ALN_URL + DATASET_URL + "&family=" + mFamily;
        URL url = new URL(urlString);
        BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
        processAlignment(in);
    }
public static boolean downloadFile(String url, String destination) {
        BufferedInputStream bi = null;
        BufferedOutputStream bo = null;
        File destfile;
        try {
            java.net.URL fileurl;
            try {
                fileurl = new java.net.URL(url);
            } catch (MalformedURLException e) {
                return false;
            }
            bi = new BufferedInputStream(fileurl.openStream());
            destfile = new File(destination);
            if (!destfile.createNewFile()) {
                destfile.delete();
                destfile.createNewFile();
            }
            bo = new BufferedOutputStream(new FileOutputStream(destfile));
            int readedbyte;
            while ((readedbyte = bi.read()) != -1) {
                bo.write(readedbyte);
            }
            bo.flush();
        } catch (IOException ex) {
            return false;
        } finally {
            try {
                bi.close();
                bo.close();
            } catch (Exception ex) {
            }
        }
        return true;
    }
public static String md5(String msg) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(msg.getBytes());
            byte[] encodedPassword = md.digest();
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < encodedPassword.length; i++) {
                if ((encodedPassword[i] & 0xff) < 0x10) {
                    sb.append("0");
                }
                sb.append(Long.toString(encodedPassword[i] & 0xff, 16));
            }
            return new String(sb.toString());
        } catch (NoSuchAlgorithmException e) {
            return null;
        }
    }
private static byte[] calcMd5(String pass) {
        try {
            MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
            digest.update(pass.getBytes(), 0, pass.length());
            byte[] hash = digest.digest();
            return hash;
        } catch (NoSuchAlgorithmException e) {
            System.err.println("No MD5 algorithm found");
            throw new RuntimeException(e);
        }
    }
static Cipher createCipher(String passwd, int mode) throws Exception {
        PBEKeySpec keySpec = new PBEKeySpec(passwd.toCharArray());
        SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
        SecretKey key = keyFactory.generateSecret(keySpec);
        MessageDigest md = MessageDigest.getInstance("MD5");
        md.update("input".getBytes());
        byte[] digest = md.digest();
        byte[] salt = new byte[8];
        for (int i = 0; i < 8; ++i) salt[i] = digest[i];
        PBEParameterSpec paramSpec = new PBEParameterSpec(salt, 20);
        Cipher cipher = Cipher.getInstance("PBEWithMD5AndDES");
        cipher.init(mode, key, paramSpec);
        return cipher;
    }
private static void unzipEntry(final ZipFile zipfile, final ZipEntry entry, final File outputDir) throws IOException {
        if (entry.isDirectory()) {
            createDir(new File(outputDir, entry.getName()));
            return;
        }
        File outputFile = new File(outputDir, entry.getName());
        if (!outputFile.getParentFile().exists()) {
            createDir(outputFile.getParentFile());
        }
        BufferedInputStream inputStream = new BufferedInputStream(zipfile.getInputStream(entry));
        BufferedOutputStream outputStream = new BufferedOutputStream(new FileOutputStream(outputFile));
        try {
            IOUtils.copy(inputStream, outputStream);
        } finally {
            outputStream.close();
            inputStream.close();
        }
    }
public static void generateCode(File flowFile, String packagePath, File destDir, File scriptRootFolder) throws IOException {
        InputStream javaSrcIn = generateCode(flowFile, packagePath, scriptRootFolder);
        File outputFolder = new File(destDir, packagePath.replace('.', File.separatorChar));
        String fileName = flowFile.getName();
        fileName = fileName.substring(0, fileName.lastIndexOf(".") + 1) + Consts.FILE_EXTENSION_GROOVY;
        File outputFile = new File(outputFolder, fileName);
        OutputStream javaSrcOut = new FileOutputStream(outputFile);
        IOUtils.copyBufferedStream(javaSrcIn, javaSrcOut);
        javaSrcIn.close();
        javaSrcOut.close();
    }
public void connected(String address, int port) {
        connected = true;
        try {
            if (localConnection) {
                byte key[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
                si.setEncryptionKey(key);
            } else {
                saveData(address, port);
                MessageDigest mds = MessageDigest.getInstance("SHA");
                mds.update(connectionPassword.getBytes("UTF-8"));
                si.setEncryptionKey(mds.digest());
            }
            if (!si.login(username, password)) {
                si.disconnect();
                connected = false;
                showErrorMessage(this, "Authentication Failure");
                restore();
                return;
            }
            SwingUtilities.invokeLater(new Runnable() {

                public void run() {
                    connectionLabel.setText("");
                    progressLabel = new JLabel("Loading... Please wait.");
                    progressLabel.setOpaque(true);
                    progressLabel.setBackground(Color.white);
                    replaceComponent(progressLabel);
                    cancelButton.setEnabled(true);
                    xx.remove(helpButton);
                }
            });
        } catch (Exception e) {
            System.out.println("connected: Exception: " + e + "\r\n");
        }
        ;
    }
public void setNewPassword(String password) {
        try {
            final MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.update(password.getBytes());
            final String encrypted = "{MD5}" + new String(Base64Encoder.encode(digest.digest()));
            setUserPassword(encrypted.getBytes());
            this.newPassword = password;
            firePropertyChange("newPassword", "", password);
            firePropertyChange("password", new byte[0], getUserPassword());
        } catch (final NoSuchAlgorithmException e) {
            throw new RuntimeException("Can't encrypt user's password", e);
        }
    }
@Test
    public void shouldSetAlias() throws Exception {
        HttpResponse response = executePost("/yum/alias/snapshots/testAlias", new StringEntity(VERSION_1));
        assertEquals(VERSION_1, EntityUtils.toString(response.getEntity()));
        assertEquals(VERSION_1, executeGet("/yum/alias/snapshots/testAlias"));
        response = executePost("/yum/alias/snapshots/testAlias", new StringEntity(VERSION_2));
        assertEquals(VERSION_2, EntityUtils.toString(response.getEntity()));
        assertEquals(VERSION_2, executeGet("/yum/alias/snapshots/testAlias"));
    }