semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public synchronized String getSerialNumber() {
        if (serialNum != null) return serialNum;
        final StringBuffer buf = new StringBuffer();
        Iterator it = classpath.iterator();
        while (it.hasNext()) {
            ClassPathEntry entry = (ClassPathEntry) it.next();
            buf.append(entry.getResourceURL().toString());
            buf.append(":");
        }
        serialNum = (String) AccessController.doPrivileged(new PrivilegedAction() {

            public Object run() {
                try {
                    MessageDigest digest = MessageDigest.getInstance("SHA");
                    digest.update(buf.toString().getBytes());
                    byte[] data = digest.digest();
                    serialNum = new BASE64Encoder().encode(data);
                    return serialNum;
                } catch (NoSuchAlgorithmException exp) {
                    BootSecurityManager.securityLogger.log(Level.SEVERE, exp.getMessage(), exp);
                    return buf.toString();
                }
            }
        });
        return serialNum;
    }
public Object run() {
                try {
                    MessageDigest digest = MessageDigest.getInstance("SHA");
                    digest.update(buf.toString().getBytes());
                    byte[] data = digest.digest();
                    serialNum = new BASE64Encoder().encode(data);
                    return serialNum;
                } catch (NoSuchAlgorithmException exp) {
                    BootSecurityManager.securityLogger.log(Level.SEVERE, exp.getMessage(), exp);
                    return buf.toString();
                }
            }
public String post() {
        if (content == null || content.equals("")) return "Type something to publish!!";
        OutputStreamWriter wr = null;
        BufferedReader rd = null;
        try {
            String data = URLEncoder.encode("api", "UTF-8") + "=" + URLEncoder.encode(apiKey, "UTF-8");
            data += "&" + URLEncoder.encode("content", "UTF-8") + "=" + URLEncoder.encode(content, "UTF-8");
            data += "&" + URLEncoder.encode("description", "UTF-8") + "=" + URLEncoder.encode(descriptionTextArea.getText() + description_suffix, "UTF-8");
            data += "&" + URLEncoder.encode("expiry", "UTF-8") + "=" + URLEncoder.encode((String) expiryComboBox.getSelectedItem(), "UTF-8");
            data += "&" + URLEncoder.encode("type", "UTF-8") + "=" + URLEncoder.encode(type, "UTF-8");
            data += "&" + URLEncoder.encode("name", "UTF-8") + "=" + URLEncoder.encode(nameTextBox.getText(), "UTF-8");
            URL url = new URL("http://pastebin.ca/quiet-paste.php");
            URLConnection conn = url.openConnection();
            conn.setDoOutput(true);
            wr = new OutputStreamWriter(conn.getOutputStream());
            wr.write(data);
            wr.flush();
            rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            line = rd.readLine();
            if (line == null || line.length() < 8 || !line.substring(0, 8).equals("SUCCESS:")) return "Unknown error in publishing the post"; else return "*Publish successful.! The link to your post is.: " + "http://pastebin.ca/" + line.substring(8);
        } catch (IOException ex) {
            return "Unable to connect to http://pastebin.ca/\nPlease check your internet connection";
        } finally {
            try {
                if (wr != null) wr.close();
                if (rd != null) rd.close();
            } catch (IOException ex) {
            }
        }
    }
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        TextView tv = new TextView(this);
        HttpClient client = new DefaultHttpClient();
        HttpGet httpGetRequest = new HttpGet("http://www.google.com/");
        String line = "", responseString = "";
        try {
            HttpResponse response = client.execute(httpGetRequest);
            if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                BufferedReader br = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
                while ((line = br.readLine()) != null) {
                    responseString += line;
                }
                br.close();
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        tv.setText(responseString);
        setContentView(tv);
    }
byte[] makeIDPFXORMask() {
        if (idpfMask == null) {
            try {
                MessageDigest sha = MessageDigest.getInstance("SHA-1");
                String temp = strip(getPrimaryIdentifier());
                sha.update(temp.getBytes("UTF-8"), 0, temp.length());
                idpfMask = sha.digest();
            } catch (NoSuchAlgorithmException e) {
                System.err.println("No such Algorithm (really, did I misspell SHA-1?");
                System.err.println(e.toString());
                return null;
            } catch (IOException e) {
                System.err.println("IO Exception. check out mask.write...");
                System.err.println(e.toString());
                return null;
            }
        }
        return idpfMask;
    }
public static void copyFile(File src, File dest, int bufSize, boolean force) throws IOException {
        if (dest.exists()) {
            if (force) {
                dest.delete();
            } else {
                throw new IOException("Cannot overwrite existing file: " + dest.getName());
            }
        }
        byte[] buffer = new byte[bufSize];
        int read = 0;
        InputStream in = null;
        OutputStream out = null;
        try {
            in = new FileInputStream(src);
            out = new FileOutputStream(dest);
            while (true) {
                read = in.read(buffer);
                if (read == -1) {
                    break;
                }
                out.write(buffer, 0, read);
            }
        } finally {
            if (in != null) {
                try {
                    in.close();
                } finally {
                    if (out != null) {
                        out.close();
                    }
                }
            }
        }
    }
@Override
    public File fetchHSMFile(String fsID, String filePath) throws HSMException {
        log.debug("fetchHSMFile called with fsID=" + fsID + ", filePath=" + filePath);
        if (absIncomingDir.mkdirs()) {
            log.info("M-WRITE " + absIncomingDir);
        }
        File tarFile;
        try {
            tarFile = File.createTempFile("hsm_", ".tar", absIncomingDir);
        } catch (IOException x) {
            throw new HSMException("Failed to create temp file in " + absIncomingDir, x);
        }
        log.info("Fetching " + filePath + " from cloud storage");
        FileOutputStream fos = null;
        try {
            if (s3 == null) createClient();
            S3Object object = s3.getObject(new GetObjectRequest(bucketName, filePath));
            fos = new FileOutputStream(tarFile);
            IOUtils.copy(object.getObjectContent(), fos);
        } catch (AmazonClientException ace) {
            s3 = null;
            throw new HSMException("Could not list objects for: " + filePath, ace);
        } catch (Exception x) {
            throw new HSMException("Failed to retrieve " + filePath, x);
        } finally {
            if (fos != null) {
                try {
                    fos.close();
                } catch (IOException e) {
                    log.error("Couldn't close output stream for: " + tarFile);
                }
            }
        }
        return tarFile;
    }
private void doOp(String urlString) {
        URL url = null;
        try {
            url = new URL(urlString);
        } catch (MalformedURLException e) {
            e.printStackTrace();
            return;
        }
        URLConnection conn = null;
        try {
            conn = url.openConnection();
            conn.setRequestProperty("Authorization", "Basic " + (new BASE64Encoder()).encode((System.getProperty("fedoragsearch.fgsUserName") + ":" + System.getProperty("fedoragsearch.fgsPassword")).getBytes()));
            conn.connect();
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        content = null;
        try {
            content = conn.getContent();
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        String line;
        BufferedReader br = new BufferedReader(new InputStreamReader((InputStream) content));
        try {
            while ((line = br.readLine()) != null) System.out.println(line);
        } catch (IOException e1) {
            e1.printStackTrace();
        }
    }
public Object execute(ExecutionEvent event) throws ExecutionException {
        try {
            Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
            QuizTreeView view = (QuizTreeView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.rcpquizengine.views.quizzes");
            Folder rootFolder = view.getRootFolder();
            if (!rootFolder.isEncrypted()) {
                PasswordDialog dialog = new PasswordDialog(shell);
                if (dialog.open() == Window.OK) {
                    String password = dialog.getPassword();
                    if (!password.equals("")) {
                        String md5 = "";
                        MessageDigest md = MessageDigest.getInstance("MD5");
                        md.update(password.getBytes());
                        md5 = new BigInteger(md.digest()).toString();
                        rootFolder.setMd5Digest(md5);
                        rootFolder.setEncrypted(true);
                        MessageDialog.openInformation(shell, "Quiz bank locked", "The current quiz bank has been locked");
                        password = "";
                        md5 = "";
                    }
                }
            } else {
                MessageDialog.openError(shell, "Error locking quiz bank", "Quiz bank already locked");
            }
        } catch (PartInitException e) {
            e.printStackTrace();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        }
        return null;
    }
public static void printResource(OutputStream os, String resourceName) throws IOException {
        InputStream is = null;
        try {
            is = ResourceLoader.loadResource(resourceName);
            if (is == null) {
                throw new IOException("Given resource not found!");
            }
            IOUtils.copy(is, os);
        } finally {
            IOUtils.closeQuietly(is);
        }
    }
public void googleImageSearch() {
        if (artist.compareToIgnoreCase(previousArtist) != 0) {
            MusicBoxView.googleImageLocation = 0;
            try {
                String u = "http://images.google.com/images?q=" + currentTrack.getArtist() + " - " + currentTrack.getAlbum() + "&sa=N&start=0&ndsp=21";
                if (u.contains(" ")) {
                    u = u.replace(" ", "+");
                }
                URL url = new URL(u);
                HttpURLConnection httpcon = (HttpURLConnection) url.openConnection();
                httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");
                BufferedReader readIn = new BufferedReader(new InputStreamReader(httpcon.getInputStream()));
                String text = "";
                String lin = "";
                while ((lin = readIn.readLine()) != null) {
                    text += lin;
                }
                readIn.close();
                if (text.contains("\n")) {
                    text = text.replace("\n", "");
                }
                String[] array = text.split("\\Qhref=\"/imgres?imgurl=\\E");
                for (String s : array) {
                    if (s.startsWith("http://") || s.startsWith("https://") && s.contains("&amp;")) {
                        String s1 = s.substring(0, s.indexOf("&amp;"));
                        googleImages.add(s1);
                    }
                }
            } catch (Exception ex4) {
                MusicBoxView.showErrorDialog(ex4);
            }
        }
    }
public void googleImageSearch(String search, String start) {
        try {
            String u = "http://images.google.com/images?q=" + search + start;
            if (u.contains(" ")) {
                u = u.replace(" ", "+");
            }
            URL url = new URL(u);
            HttpURLConnection httpcon = (HttpURLConnection) url.openConnection();
            httpcon.addRequestProperty("User-Agent", "Mozilla/4.76");
            BufferedReader readIn = new BufferedReader(new InputStreamReader(httpcon.getInputStream()));
            googleImages.clear();
            String text = "";
            String lin = "";
            while ((lin = readIn.readLine()) != null) {
                text += lin;
            }
            readIn.close();
            if (text.contains("\n")) {
                text = text.replace("\n", "");
            }
            String[] array = text.split("\\Qhref=\"/imgres?imgurl=\\E");
            for (String s : array) {
                if (s.startsWith("http://") || s.startsWith("https://") && s.contains("&amp;")) {
                    String s1 = s.substring(0, s.indexOf("&amp;"));
                    googleImages.add(s1);
                }
            }
        } catch (Exception ex4) {
            MusicBoxView.showErrorDialog(ex4);
        }
        MusicBoxView.jButton7.setEnabled(true);
        ImageIcon icon;
        try {
            icon = new ImageIcon(new URL(googleImages.elementAt(MusicBoxView.googleImageLocation)));
            ImageIcon ico = new ImageIcon(icon.getImage().getScaledInstance(100, 100, Image.SCALE_SMOOTH));
            MusicBoxView.albumArtLabel.setIcon(ico);
        } catch (MalformedURLException ex1) {
            MusicBoxView.showErrorDialog(ex1);
        }
    }
private static Vector<String> getIgnoreList() {
        try {
            URL url = DeclarationTranslation.class.getClassLoader().getResource("ignorelist");
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(url.openStream()));
            Vector<String> ret = new Vector<String>();
            String line = null;
            while ((line = bufferedReader.readLine()) != null) {
                ret.add(line);
            }
            return ret;
        } catch (Exception e) {
            return null;
        }
    }
public long saveDB(Connection con, long id, boolean commit) throws SQLException {
        StringBuffer SQL = null;
        Statement statement = null;
        ResultSet result_set = null;
        try {
            statement = con.createStatement();
            if (id < 0) {
                id = QueryUtils.sequenceGetNextID(con, "PATTERN_OUTLINE");
            } else {
                deleteDB(con, id);
            }
            SQL = new StringBuffer("insert into ");
            SQL.append("PATTERN_OUTLINE values (");
            SQL.append(id);
            SQL.append(",");
            SQL.append(XColor.toInt(pattern.getPatternColor()));
            SQL.append(",");
            SQL.append(pattern.getPatternStyle());
            SQL.append(",");
            SQL.append(pattern.getPatternDensity());
            SQL.append(",");
            SQL.append(XColor.toInt(pattern.getBackgroundColor()));
            SQL.append(",");
            SQL.append(XColor.toInt(outline.getColor()));
            SQL.append(",");
            SQL.append(outline.getStyle());
            SQL.append(",");
            SQL.append(outline.getWidth());
            SQL.append(")");
            statement.executeUpdate(new String(SQL));
            SQL = null;
            if (commit) {
                con.commit();
            }
        } catch (SQLException e) {
            System.err.println(getClass().getName() + ":" + e + " SQL:=" + SQL);
            if (commit) {
                con.rollback();
            }
            throw e;
        } finally {
            if (statement != null) {
                try {
                    statement.close();
                } 
		catch (SQLException e) {
		
		}
            }
	}
	return saveDB(con, id, false);
}
public BasicTraceImpl() {
        out = System.out;
        traceEnable = new HashMap();
        URL url = Hive.getURL("trace.cfg");
        if (url != null) try {
            InputStream input = url.openStream();
            BufferedReader in = new BufferedReader(new InputStreamReader(input));
            String line;
            for (line = line = in.readLine(); line != null; line = in.readLine()) {
                int i = line.indexOf("=");
                if (i > 0) {
                    String name = line.substring(0, i).trim();
                    String value = line.substring(i + 1).trim();
                    traceEnable.put(name, Boolean.valueOf(value).booleanValue() ? ((Object) (Boolean.TRUE)) : ((Object) (Boolean.FALSE)));
                }
            }
            input.close();
        } catch (IOException io) {
            System.out.println(io);
        }
        TRACE = getEnable(THIS);
    }
void startzm() {
        URL myzzurl;
        InputStream myzstream;
        byte zmemimage[];
        boolean joined;
        zmemimage = null;
        try {
            System.err.println(zcodefile);
            myzzurl = new URL(zcodefile);
            myzstream = myzzurl.openStream();
            zmemimage = suckstream(myzstream);
        } catch (MalformedURLException booga) {
            try {
                myzstream = new FileInputStream(zcodefile);
                zmemimage = suckstream(myzstream);
            } catch (IOException booga2) {
                add("North", new Label("Malformed URL"));
                failed = true;
            }
        } catch (IOException booga) {
            add("North", new Label("I/O Error"));
        }
        if (zmemimage != null) {
            switch(zmemimage[0]) {
                case 3:
                    zm = new ZMachine3(screen, status_line, zmemimage);
                    break;
                case 5:
                    remove(status_line);
                    zm = new ZMachine5(screen, zmemimage);
                    break;
                case 8:
                    remove(status_line);
                    zm = new ZMachine8(screen, zmemimage);
                    break;
                default:
                    add("North", new Label("Not a valid V3,V5, or V8 story file"));
            }
            if (zm != null) zm.start();
        }
        joined = false;
        if (zmemimage != null) {
            while (!joined) {
                try {
                    zm.join();
                    joined = true;
                } catch (InterruptedException booga) {
                }
            }
        }
        System.exit(0);
    }
private long generateUnixInstallShell(File unixShellFile, String instTemplate, File instClassFile) throws IOException {
        FileOutputStream byteWriter = new FileOutputStream(unixShellFile);
        InputStream is = getClass().getResourceAsStream("/" + instTemplate);
        InputStreamReader isr = new InputStreamReader(is);
        LineNumberReader reader = new LineNumberReader(isr);
        String content = "";
        String installClassStartStr = "000000000000";
        NumberFormat nf = NumberFormat.getInstance(Locale.US);
        nf.setGroupingUsed(false);
        nf.setMinimumIntegerDigits(installClassStartStr.length());
        int installClassStartPos = 0;
        long installClassOffset = 0;
        System.out.println(VAGlobals.i18n("VAArchiver_GenerateInstallShell"));
        String line = reader.readLine();
        while ((line != null) && (!line.startsWith("# InstallClassStart"))) {
            content += line + "\n";
            line = reader.readLine();
        }
        content += "InstallClassStart=" + installClassStartStr + "\n";
        installClassStartPos = content.length() - 1 - 1 - installClassStartStr.length();
        line = reader.readLine();
        while ((line != null) && (!line.startsWith("# InstallClassSize"))) {
            content += line + "\n";
            line = reader.readLine();
        }
        content += new String("InstallClassSize=" + instClassFile.length() + "\n");
        line = reader.readLine();
        while ((line != null) && (!line.startsWith("# InstallClassName"))) {
            content += line + "\n";
            line = reader.readLine();
        }
        content += new String("InstallClassName=" + instClassName_ + "\n");
        line = reader.readLine();
        while ((line != null) && (!line.startsWith("# Install class"))) {
            content += line + "\n";
            line = reader.readLine();
        }
        if (line != null) content += line + "\n";
        byteWriter.write(content.substring(0, installClassStartPos + 1).getBytes());
        byteWriter.write(nf.format(content.length()).getBytes());
        byteWriter.write(content.substring(installClassStartPos + 1 + installClassStartStr.length()).getBytes());
        installClassOffset = content.length();
        content = null;
        FileInputStream classStream = new FileInputStream(instClassFile);
        byte[] buf = new byte[2048];
        int read = classStream.read(buf);
        while (read > 0) {
            byteWriter.write(buf, 0, read);
            read = classStream.read(buf);
        }
        classStream.close();
        reader.close();
        byteWriter.close();
        return installClassOffset;
    }
private void appendArchive(File instClass) throws IOException {
        FileOutputStream out = new FileOutputStream(instClass.getName(), true);
        FileInputStream zipStream = new FileInputStream("install.jar");
        byte[] buf = new byte[2048];
        int read = zipStream.read(buf);
        while (read > 0) {
            out.write(buf, 0, read);
            read = zipStream.read(buf);
        }
        zipStream.close();
        out.close();
    }
private void copy(File fin, File fout) throws IOException {
        FileOutputStream out = null;
        FileInputStream in = null;
        try {
            out = new FileOutputStream(fout);
            in = new FileInputStream(fin);
            byte[] buf = new byte[2048];
            int read = in.read(buf);
            while (read > 0) {
                out.write(buf, 0, read);
                read = in.read(buf);
            }
        } catch (IOException _e) {
            throw _e;
        } finally {
            if (in != null) in.close();
            if (out != null) out.close();
        }
    }
public static void copyFile(File source, File destination) throws IOException {
        FileChannel in = null;
        FileChannel out = null;
        try {
            in = new FileInputStream(source).getChannel();
            out = new FileOutputStream(destination).getChannel();
            long size = in.size();
            MappedByteBuffer buffer = in.map(FileChannel.MapMode.READ_ONLY, 0, size);
            out.write(buffer);
        } finally {
            if (in != null) {
                in.close();
            }
            if (out != null) {
                out.close();
            }
        }
    }
public Blowfish(String password) {
        MessageDigest digest = null;
        try {
            digest = MessageDigest.getInstance("SHA1");
            digest.update(password.getBytes());
        } catch (Exception e) {
            Log.error(e.getMessage(), e);
        }
        m_bfish = new BlowfishCBC(digest.digest(), 0);
        digest.reset();
    }