semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public static Image load(final InputStream input, String format, Point dimension) throws CoreException {
        MultiStatus status = new MultiStatus(GraphVizActivator.ID, 0, "Errors occurred while running Graphviz", null);
        File dotInput = null, dotOutput = null;
        ByteArrayOutputStream dotContents = new ByteArrayOutputStream();
        try {
            dotInput = File.createTempFile(TMP_FILE_PREFIX, DOT_EXTENSION);
            dotOutput = File.createTempFile(TMP_FILE_PREFIX, "." + format);
            dotOutput.delete();
            FileOutputStream tmpDotOutputStream = null;
            try {
                IOUtils.copy(input, dotContents);
                tmpDotOutputStream = new FileOutputStream(dotInput);
                IOUtils.copy(new ByteArrayInputStream(dotContents.toByteArray()), tmpDotOutputStream);
            } finally {
                IOUtils.closeQuietly(tmpDotOutputStream);
            }
            IStatus result = runDot(format, dimension, dotInput, dotOutput);
            status.add(result);
            status.add(logInput(dotContents));
            if (dotOutput.isFile()) {
                if (!result.isOK() && Platform.inDebugMode()) LogUtils.log(status);
                ImageLoader loader = new ImageLoader();
                ImageData[] imageData = loader.load(dotOutput.getAbsolutePath());
                return new Image(Display.getDefault(), imageData[0]);
            }
        } catch (SWTException e) {
            status.add(new Status(IStatus.ERROR, GraphVizActivator.ID, "", e));
        } catch (IOException e) {
            status.add(new Status(IStatus.ERROR, GraphVizActivator.ID, "", e));
        } finally {
            dotInput.delete();
            dotOutput.delete();
            IOUtils.closeQuietly(input);
        }
        throw new CoreException(status);
    }
public void testAutoCommit() throws Exception {
        Connection con = getConnectionOverrideProperties(new Properties());
        try {
            Statement stmt = con.createStatement();
            assertEquals(0, stmt.executeUpdate("create table #testAutoCommit (i int)"));
            con.setAutoCommit(false);
            assertEquals(1, stmt.executeUpdate("insert into #testAutoCommit (i) values (0)"));
            con.setAutoCommit(false);
            con.rollback();
            assertEquals(1, stmt.executeUpdate("insert into #testAutoCommit (i) values (1)"));
            con.setAutoCommit(true);
            con.setAutoCommit(false);
            con.rollback();
            con.setAutoCommit(true);
            ResultSet rs = stmt.executeQuery("select i from #testAutoCommit");
            assertTrue(rs.next());
            assertEquals(1, rs.getInt(1));
            assertFalse(rs.next());
            rs.close();
            stmt.close();
        } finally {
            con.close();
        }
    }
public static void main(String[] args) {
        for (int i = 0; i < args.length - 2; i++) {
            if (!CommonArguments.parseArguments(args, i, u)) {
                u.usage();
                System.exit(1);
            }
            if (CommonParameters.startArg > (i + 1)) i = CommonParameters.startArg - 1;
        }
        if (args.length < CommonParameters.startArg + 2) {
            u.usage();
            System.exit(1);
        }
        try {
            int readsize = 1024;
            ContentName argName = ContentName.fromURI(args[CommonParameters.startArg]);
            CCNHandle handle = CCNHandle.open();
            File theFile = new File(args[CommonParameters.startArg + 1]);
            if (theFile.exists()) {
                System.out.println("Overwriting file: " + args[CommonParameters.startArg + 1]);
            }
            FileOutputStream output = new FileOutputStream(theFile);
            long starttime = System.currentTimeMillis();
            CCNInputStream input;
            if (CommonParameters.unversioned) input = new CCNInputStream(argName, handle); else input = new CCNFileInputStream(argName, handle);
            if (CommonParameters.timeout != null) {
                input.setTimeout(CommonParameters.timeout);
            }
            byte[] buffer = new byte[readsize];
            int readcount = 0;
            long readtotal = 0;
            while ((readcount = input.read(buffer)) != -1) {
                readtotal += readcount;
                output.write(buffer, 0, readcount);
                output.flush();
            }
            if (CommonParameters.verbose) System.out.println("ccngetfile took: " + (System.currentTimeMillis() - starttime) + "ms");
            System.out.println("Retrieved content " + args[CommonParameters.startArg + 1] + " got " + readtotal + " bytes.");
            System.exit(0);
        } catch (ConfigurationException e) {
            System.out.println("Configuration exception in ccngetfile: " + e.getMessage());
            e.printStackTrace();
        } catch (MalformedContentNameStringException e) {
            System.out.println("Malformed name: " + args[CommonParameters.startArg] + " " + e.getMessage());
            e.printStackTrace();
        } catch (IOException e) {
            System.out.println("Cannot write file or read content. " + e.getMessage());
            e.printStackTrace();
        }
        System.exit(1);
    }
private static String GetSHA1(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
        MessageDigest md;
        md = MessageDigest.getInstance("SHA-1");
        byte[] sha1hash = new byte[40];
        md.update(text.getBytes("iso-8859-1"), 0, text.length());
        sha1hash = md.digest();
        return LoginHttpPostProcessor.ConvertToHex(sha1hash);
    }
public void executeUpdateTransaction(List queries) throws SQLException {
        assert connection != null;
        boolean autoCommit = connection.getAutoCommit();
        connection.setAutoCommit(false);
        try {
            Iterator iterator = queries.iterator();
            while (iterator.hasNext()) {
                String query = (String) iterator.next();
                Statement statement = connection.createStatement();
                statement.executeUpdate(query);
            }
            connection.commit();
            connection.setAutoCommit(autoCommit);
        } catch (SQLException e) {
            connection.rollback();
            throw new SQLException(e.getMessage());
        }
    }
protected String readFileUsingFileUrl(String fileUrlName) {
        String response = "";
        try {
            URL url = new URL(fileUrlName);
            URLConnection connection = url.openConnection();
            InputStreamReader isr = new InputStreamReader(connection.getInputStream());
            BufferedReader in = new BufferedReader(isr);
            String inputLine = "";
            while ((inputLine = in.readLine()) != null) {
                response += inputLine + "\n";
            }
            if (response.endsWith("\n")) {
                response = response.substring(0, response.length() - 1);
            }
            in.close();
        } catch (Exception x) {
            x.printStackTrace();
        }
        return response;
    }
protected String readFileUsingHttp(String fileUrlName) {
        String response = "";
        try {
            URL url = new URL(fileUrlName);
            URLConnection connection = url.openConnection();
            HttpURLConnection httpConn = (HttpURLConnection) connection;
            httpConn.setRequestProperty("Content-Type", "text/html");
            httpConn.setRequestProperty("Content-Length", "0");
            httpConn.setRequestMethod("GET");
            httpConn.setDoOutput(true);
            httpConn.setDoInput(true);
            httpConn.setAllowUserInteraction(false);
            InputStreamReader isr = new InputStreamReader(httpConn.getInputStream());
            BufferedReader in = new BufferedReader(isr);
            String inputLine = "";
            while ((inputLine = in.readLine()) != null) {
                response += inputLine + "\n";
            }
            if (response.endsWith("\n")) {
                response = response.substring(0, response.length() - 1);
            }
            in.close();
        } catch (Exception x) {
            x.printStackTrace();
        }
        return response;
    }
public static List<ServerInfo> getStartedServers() {
        List<ServerInfo> infos = new ArrayList<ServerInfo>();
        try {
            StringBuilder request = new StringBuilder();
            request.append(url).append("/").append(displayServlet);
            request.append("?ingame=1");
            URL objUrl = new URL(request.toString());
            URLConnection urlConnect = objUrl.openConnection();
            InputStream in = urlConnect.getInputStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(in));
            while (reader.ready()) {
                String name = reader.readLine();
                String ip = reader.readLine();
                int port = Integer.valueOf(reader.readLine());
                ServerInfo server = new ServerInfo(name, ip, port);
                server.nbPlayers = Integer.valueOf(reader.readLine());
                infos.add(server);
            }
            in.close();
            return infos;
        } catch (Exception e) {
            return infos;
        }
    }
public int[] bubbleSort(int[] data) {
        for (int i = 0; i < data.length; i++) {
            for (int j = 0; j < data.length - i - 1; j++) {
                if (data[j] > data[j + 1]) {
                    int temp = data[j];
                    data[j] = data[j + 1];
                    data[j + 1] = temp;
                }
            }
        }
        return data;
    }
private void findFile() throws SchedulerException {
        java.io.InputStream f = null;
        String furl = null;
        File file = new File(getFileName());
        if (!file.exists()) {
            URL url = classLoadHelper.getResource(getFileName());
            if (url != null) {
                try {
                    furl = URLDecoder.decode(url.getPath(), "UTF-8");
                    file = new File(furl);
                    f = url.openStream();
                } catch (java.io.UnsupportedEncodingException uee) {
                } catch (IOException ignor) {
                }
            }
        } else {
            try {
                f = new java.io.FileInputStream(file);
            } catch (FileNotFoundException e) {
            }
        }
        if (f == null && isFailOnFileNotFound()) {
            throw new SchedulerException("File named '" + getFileName() + "' does not exist. f == null && isFailOnFileNotFound()");
        } else if (f == null) {
            getLog().warn("File named '" + getFileName() + "' does not exist. f == null");
        } else {
            fileFound = true;
            try {
                if (furl != null) this.filePath = furl; else this.filePath = file.getAbsolutePath();
                f.close();
            } catch (IOException ioe) {
                getLog().warn("Error closing jobs file " + getFileName(), ioe);
            }
        }
    }
@Override
    public String getPath() {
        InputStream in = null;
        OutputStream out = null;
        File file = null;
        try {
            file = File.createTempFile("java-storage_" + RandomStringUtils.randomAlphanumeric(32), ".tmp");
            file.deleteOnExit();
            out = new FileOutputStream(file);
            in = openStream();
            IOUtils.copy(in, out);
        } catch (IOException e) {
            throw new RuntimeException();
        } finally {
            IOUtils.closeQuietly(in);
            IOUtils.closeQuietly(out);
        }
        if (file != null && file.exists()) {
            return file.getPath();
        }
        return null;
    }
public static void copy(File file, File dir, boolean overwrite) throws IOException {
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
        File out = new File(dir, file.getName());
        if (out.exists() && !overwrite) {
            throw new IOException("File: " + out + " already exists.");
        }
        FileOutputStream fos = new FileOutputStream(out, false);
        byte[] block = new byte[4096];
        int read = bis.read(block);
        while (read != -1) {
            fos.write(block, 0, read);
            read = bis.read(block);
        }
    }
public void createBankSignature() {
        byte b;
        try {
            _bankMessageDigest = MessageDigest.getInstance("MD5");
            _bankSig = Signature.getInstance("MD5/RSA/PKCS#1");
            _bankSig.initSign((PrivateKey) _bankPrivateKey);
            _bankMessageDigest.update(getBankString().getBytes());
            _bankMessageDigestBytes = _bankMessageDigest.digest();
            _bankSig.update(_bankMessageDigestBytes);
            _bankSignatureBytes = _bankSig.sign();
        } catch (Exception e) {
        }
        ;
    }
public void createVendorSignature() {
        byte b;
        try {
            _vendorMessageDigest = MessageDigest.getInstance("MD5");
            _vendorSig = Signature.getInstance("MD5/RSA/PKCS#1");
            _vendorSig.initSign((PrivateKey) _vendorPrivateKey);
            _vendorMessageDigest.update(getBankString().getBytes());
            _vendorMessageDigestBytes = _vendorMessageDigest.digest();
            _vendorSig.update(_vendorMessageDigestBytes);
            _vendorSignatureBytes = _vendorSig.sign();
        } catch (Exception e) {
        }
        ;
    }
public static URL getComponentXmlFileWith(String name) throws Exception {
        List<URL> all = getComponentXmlFiles();
        for (URL url : all) {
            InputStream stream = null;
            try {
                stream = url.openStream();
                Element root = XML.getRootElement(stream);
                for (Element elem : (List<Element>) root.elements()) {
                    String ns = elem.getNamespace().getURI();
                    if (name.equals(elem.attributeValue("name"))) {
                        return url;
                    }
                }
            } finally {
                Resources.closeStream(stream);
            }
        }
        return null;
    }
public String loadURLString(java.net.URL url) {
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
            StringBuffer buf = new StringBuffer();
            String s = "";
            while (br.ready() && s != null) {
                s = br.readLine();
                if (s != null) {
                    buf.append(s);
                    buf.append("\n");
                }
            }
            return buf.toString();
        } catch (IOException ex) {
            return "";
        } catch (NullPointerException npe) {
            return "";
        }
    }
public void removeResource(String resourceID, String sql, String[] keys) throws XregistryException {
        try {
            Connection connection = globalContext.createConnection();
            connection.setAutoCommit(false);
            PreparedStatement statement = null;
            try {
                statement = connection.prepareStatement(sql);
                for (int i = 0; i < keys.length; i++) {
                    statement.setString(i + 1, keys[i]);
                }
                statement.executeUpdate();
                statement = connection.prepareStatement(DELETE_RESOURCE_SQL);
                statement.setString(1, resourceID);
                statement.executeUpdate();
                log.info("Execuate SQL " + statement);
                connection.commit();
            } catch (SQLException e) {
                connection.rollback();
                throw new XregistryException(e);
            } finally {
                try {
                    statement.close();
                    connection.setAutoCommit(true);
                    globalContext.closeConnection(connection);
                } catch (SQLException e) {
                    throw new XregistryException(e);
                }
            }
        } catch (SQLException e) {
            throw new XregistryException(e);
        }
    }
public String generateMappackMD5(File mapPackFile) throws IOException, NoSuchAlgorithmException {
        ZipFile zip = new ZipFile(mapPackFile);
        try {
            Enumeration<? extends ZipEntry> entries = zip.entries();
            MessageDigest md5Total = MessageDigest.getInstance("MD5");
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            while (entries.hasMoreElements()) {
                ZipEntry entry = entries.nextElement();
                if (entry.isDirectory()) continue;
                String name = entry.getName();
                if (name.toUpperCase().startsWith("META-INF")) continue;
                md5.reset();
                InputStream in = zip.getInputStream(entry);
                byte[] data = Utilities.getInputBytes(in);
                in.close();
                byte[] digest = md5.digest(data);
                log.trace("Hashsum " + Hex.encodeHexString(digest) + " includes \"" + name + "\"");
                md5Total.update(digest);
                md5Total.update(name.getBytes());
            }
            String md5sum = Hex.encodeHexString(md5Total.digest());
            log.trace("md5sum of " + mapPackFile.getName() + ": " + md5sum);
            return md5sum;
        } finally {
            zip.close();
        }
    }
public static void main(String[] args) throws Exception {
        BufferedImage image = ImageIO.read(BitmapFont.class.getResource("Candara-38-Bold.png"));
        URL url = BitmapFontData.class.getResource("Candara-38-Bold.fnt");
        BitmapFontData bitmapFontData = new BitmapFontData(url.openStream(), true);
        BitmapFont font = new BitmapFont(bitmapFontData, true);
        font.drawMultiLine("Hello world\nthis is a\ntest!!!", 100, 100);
        VertexData vertexData = font.createVertexData();
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.create();
        RenderPass renderPass = new RenderPass();
        renderPass.setClearMask(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        renderPass.setClearColor(new Color4f(0.3f, 0.4f, 0.5f, 1f));
        renderPass.setView(View.createOrtho(0, 640, 0, 480, -1000, 1000));
        ByteBuffer[][] pixels = { { TextureLoader.getImageData(image) } };
        Texture texture = new Texture(TextureType.TEXTURE_2D, 4, image.getWidth(), image.getHeight(), 0, Format.BGRA, pixels, false, false);
        Shape shape = new Shape(vertexData);
        shape.getState().setUnit(0, new Unit(texture));
        shape.getState().setBlendEnabled(true);
        shape.getState().setBlendSrcFunc(BlendSrcFunc.SRC_ALPHA);
        shape.getState().setBlendDstFunc(BlendDstFunc.ONE_MINUS_SRC_ALPHA);
        renderPass.getRootNode().addShape(shape);
        Renderer renderer = new Renderer(new SceneGraph(renderPass));
        while (!Display.isCloseRequested()) {
            renderer.render();
            Display.update();
        }
        Display.destroy();
    }
public static void fileUpload() throws IOException {
        HttpClient httpclient = new DefaultHttpClient();
        httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
        file = new File("H:\\FileServeUploader.java");
        HttpPost httppost = new HttpPost(postURL);
        httppost.setHeader("Cookie", uprandcookie + ";" + autologincookie);
        MultipartEntity mpEntity = new MultipartEntity();
        ContentBody cbFile = new FileBody(file);
        mpEntity.addPart("MAX_FILE_SIZE", new StringBody("2097152000"));
        mpEntity.addPart("UPLOAD_IDENTIFIER", new StringBody(uid));
        mpEntity.addPart("go", new StringBody("1"));
        mpEntity.addPart("files", cbFile);
        httppost.setEntity(mpEntity);
        System.out.println("Now uploading your file into depositfiles...........................");
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();
        System.out.println(response.getStatusLine());
        if (resEntity != null) {
            uploadresponse = EntityUtils.toString(resEntity);
            downloadlink = parseResponse(uploadresponse, "ud_download_url = '", "'");
            deletelink = parseResponse(uploadresponse, "ud_delete_url = '", "'");
            System.out.println("download link : " + downloadlink);
            System.out.println("delete link : " + deletelink);
        }
    }
@Override
    public void sendContent(OutputStream out, Range range, Map<String, String> params, String contentType) throws IOException {
        LOGGER.debug("DOWNLOAD - Send content: " + realFile.getAbsolutePath());
        LOGGER.debug("Output stream: " + out.toString());
        if (ServerConfiguration.isDynamicSEL()) {
            LOGGER.error("IS DINAMIC SEL????");
        } else {
        }
        if (".tokens".equals(realFile.getName()) || ".response".equals(realFile.getName()) || ".request".equals(realFile.getName()) || isAllowedClient) {
            FileInputStream in = null;
            try {
                in = new FileInputStream(realFile);
                int bytes = IOUtils.copy(in, out);
                LOGGER.debug("System resource or Allowed Client wrote bytes:  " + bytes);
                out.flush();
            } catch (Exception e) {
                LOGGER.error("Error while uploading over encryption system " + realFile.getName() + " file", e);
            } finally {
                IOUtils.closeQuietly(in);
            }
        } else {
            FileInputStream in = null;
            try {
                in = new FileInputStream(realFile);
                int bytes = IOUtils.copy(in, out);
                LOGGER.debug("System resource or Allowed Client wrote bytes:  " + bytes);
                out.flush();
            } catch (Exception e) {
                LOGGER.error("Error while uploading over encryption system " + realFile.getName() + " file", e);
            } finally {
                IOUtils.closeQuietly(in);
            }
        }
    }
private void bokActionPerformed(java.awt.event.ActionEvent evt) {
        Vector vret = this.uniformtitlepanel.getEnteredValuesKeys();
        String[] patlib = newgen.presentation.NewGenMain.getAppletInstance().getPatronLibraryIds();
        String xmlreq = newgen.presentation.administration.AdministrationXMLGenerator.getInstance().saveUniformTitleSH("2", vret, patlib);
        System.out.println(xmlreq);
        try {
            java.net.URL url = new java.net.URL(ResourceBundle.getBundle("Administration").getString("ServerURL") + ResourceBundle.getBundle("Administration").getString("ServletSubPath") + "UniformTitleSubjectHeadingServlet");
            java.net.URLConnection urlconn = (java.net.URLConnection) url.openConnection();
            urlconn.setDoOutput(true);
            java.io.OutputStream dos = urlconn.getOutputStream();
            dos.write(xmlreq.getBytes());
            java.io.InputStream ios = urlconn.getInputStream();
            SAXBuilder saxb = new SAXBuilder();
            Document retdoc = saxb.build(ios);
            Element rootelement = retdoc.getRootElement();
            if (rootelement.getChild("Error") == null) {
                this.showInformationMessage(ResourceBundle.getBundle("Administration").getString("DataSavedInDatabase"));
            } else {
                this.showErrorMessage(ResourceBundle.getBundle("Administration").getString("ErrorPleaseContactTheVendor"));
            }
        } catch (Exception e) {
            System.out.println(e);
        }
    }