semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public void copyNIO(File in, File out) throws IOException {
        FileInputStream inStream = null;
        FileOutputStream outStream = null;
        FileChannel sourceChannel = null;
        FileChannel destinationChannel = null;
        try {
            inStream = new FileInputStream(in);
            outStream = new FileOutputStream(out);
            sourceChannel = inStream.getChannel();
            destinationChannel = outStream.getChannel();
            destinationChannel.transferFrom(sourceChannel, 0, sourceChannel.size());
        } finally {
            if (sourceChannel != null) sourceChannel.close();
            if (destinationChannel != null) destinationChannel.close();
            if (inStream != null) inStream.close();
            if (outStream != null) outStream.close();
        }
    }
private void bokActionPerformed(java.awt.event.ActionEvent evt) {
        if (this.meetingnamepanel.getEnteredValues().get(0).toString().trim().equals("")) {
            this.showWarningMessage("Enter Meeting Name");
        } else {
            String[] patlib = newgen.presentation.NewGenMain.getAppletInstance().getPatronLibraryIds();
            String xmlreq = newgen.presentation.administration.AdministrationXMLGenerator.getInstance().saveMeetingName("2", meetingnamepanel.getEnteredValues(), patlib);
            try {
                java.net.URL url = new java.net.URL(ResourceBundle.getBundle("Administration").getString("ServerURL") + ResourceBundle.getBundle("Administration").getString("ServletSubPath") + "MeetingNameServlet");
                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);
            }
        }
    }
private void copyXsl(File aTargetLogDir) {
        Trace.println(Trace.LEVEL.UTIL, "copyXsl( " + aTargetLogDir.getName() + " )", true);
        if (myXslSourceDir == null) {
            return;
        }
        File[] files = myXslSourceDir.listFiles();
        for (int i = 0; i < files.length; i++) {
            File srcFile = files[i];
            if (!srcFile.isDirectory()) {
                File tgtFile = new File(aTargetLogDir + File.separator + srcFile.getName());
                FileChannel inChannel = null;
                FileChannel outChannel = null;
                try {
                    inChannel = new FileInputStream(srcFile).getChannel();
                    outChannel = new FileOutputStream(tgtFile).getChannel();
                    inChannel.transferTo(0, inChannel.size(), outChannel);
                } catch (IOException e) {
                    throw new IOError(e);
                } finally {
                    if (inChannel != null) try {
                        inChannel.close();
                    } catch (IOException exc) {
                        throw new IOError(exc);
                    }
                    if (outChannel != null) try {
                        outChannel.close();
                    } catch (IOException exc) {
                        throw new IOError(exc);
                    }
                }
            }
        }
    }
public static Shader loadShader(String vspath, String fspath, int textureUnits, boolean separateCam, boolean fog) throws ShaderProgramProcessException {
        if (vspath == "" || fspath == "") return null;
        BufferedReader in;
        String vert = "", frag = "";
        try {
            URL v_url = Graphics.class.getClass().getResource("/eu/cherrytree/paj/graphics/shaders/" + vspath);
            String v_path = AppDefinition.getDefaultDataPackagePath() + "/shaders/" + vspath;
            if (v_url != null) in = new BufferedReader(new InputStreamReader(v_url.openStream())); else in = new BufferedReader(new InputStreamReader(new FileReader(v_path).getInputStream()));
            boolean run = true;
            String str;
            while (run) {
                str = in.readLine();
                if (str != null) vert += str + "\n"; else run = false;
            }
            in.close();
        } catch (Exception e) {
            System.err.println("Couldn't read in vertex shader \"" + vspath + "\".");
            throw new ShaderNotLoadedException(vspath, fspath);
        }
        try {
            URL f_url = Graphics.class.getClass().getResource("/eu/cherrytree/paj/graphics/shaders/" + fspath);
            String f_path = AppDefinition.getDefaultDataPackagePath() + "/shaders/" + fspath;
            if (f_url != null) in = new BufferedReader(new InputStreamReader(f_url.openStream())); else in = new BufferedReader(new InputStreamReader(new FileReader(f_path).getInputStream()));
            boolean run = true;
            String str;
            while (run) {
                str = in.readLine();
                if (str != null) frag += str + "\n"; else run = false;
            }
            in.close();
        } catch (Exception e) {
            System.err.println("Couldn't read in fragment shader \"" + fspath + "\".");
            throw new ShaderNotLoadedException(vspath, fspath);
        }
        return loadShaderFromSource(vert, frag, textureUnits, separateCam, fog);
    }
private byte[] getMergedContent(List names, ServletContext servletContext) throws IOException {
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        for (Iterator iterator = names.iterator(); iterator.hasNext(); ) {
            String path = (String) iterator.next();
            if (!path.startsWith("/")) path = "/" + path;
            URL url = servletContext.getResource(path);
            if (url == null) url = getClass().getResource(path);
            if (url == null) throw new IOException("The resources '" + path + "' could not be found neither in the webapp folder nor in a jar");
            log.debug("Merging content of group : " + getName());
            InputStream inputStream = url.openStream();
            InputStreamReader r = new InputStreamReader(inputStream);
            IOUtils.copy(r, baos, "ASCII");
            baos.write((byte) '\n');
            inputStream.close();
        }
        baos.close();
        return baos.toByteArray();
    }
public synchronized void connectURL(String url) throws IllegalArgumentException, IOException, MalformedURLException {
        URL myurl = new URL(url);
        InputStream in = myurl.openStream();
        BufferedReader page = new BufferedReader(new InputStreamReader(in));
        String ior = null;
        ArrayList nodesAL = new ArrayList();
        while ((ior = page.readLine()) != null) {
            if (ior.trim().equals("")) continue;
            nodesAL.add(ior);
        }
        in.close();
        Object[] nodesOA = nodesAL.toArray();
        Node[] nodes = new Node[nodesOA.length];
        for (int i = 0; i < nodesOA.length; i++) nodes[i] = TcbnetOrb.getInstance().getNode((String) nodesOA[i]);
        this.connect(nodes);
    }
private static List retrieveQuotes(Report report, Symbol symbol, TradingDate startDate, TradingDate endDate) throws ImportExportException {
        List quotes = new ArrayList();
        String URLString = constructURL(symbol, startDate, endDate);
        EODQuoteFilter filter = new YahooEODQuoteFilter(symbol);
        PreferencesManager.ProxyPreferences proxyPreferences = PreferencesManager.loadProxySettings();
        try {
            URL url = new URL(URLString);
            InputStreamReader input = new InputStreamReader(url.openStream());
            BufferedReader bufferedInput = new BufferedReader(input);
            String line = bufferedInput.readLine();
            while (line != null) {
                line = bufferedInput.readLine();
                if (line != null) {
                    try {
                        EODQuote quote = filter.toEODQuote(line);
                        quotes.add(quote);
                        verify(report, quote);
                    } catch (QuoteFormatException e) {
                        report.addError(Locale.getString("YAHOO") + ":" + symbol + ":" + Locale.getString("ERROR") + ": " + e.getMessage());
                    }
                }
            }
            bufferedInput.close();
        } catch (BindException e) {
            throw new ImportExportException(Locale.getString("UNABLE_TO_CONNECT_ERROR", e.getMessage()));
        } catch (ConnectException e) {
            throw new ImportExportException(Locale.getString("UNABLE_TO_CONNECT_ERROR", e.getMessage()));
        } catch (UnknownHostException e) {
            throw new ImportExportException(Locale.getString("UNKNOWN_HOST_ERROR", e.getMessage()));
        } catch (NoRouteToHostException e) {
            throw new ImportExportException(Locale.getString("DESTINATION_UNREACHABLE_ERROR", e.getMessage()));
        } catch (MalformedURLException e) {
            throw new ImportExportException(Locale.getString("INVALID_PROXY_ERROR", proxyPreferences.host, proxyPreferences.port));
        } catch (FileNotFoundException e) {
        } catch (IOException e) {
            throw new ImportExportException(Locale.getString("ERROR_DOWNLOADING_QUOTES"));
        }
        return quotes;
    }
@Override
    public EntrySet read(EntrySet set) throws ReadFailedException {
        if (!SourceCache.contains(url)) {
            SSL.certify(url);
            try {
                super.setParser(Parser.detectParser(url.openStream(), url));
                final PipedInputStream in = new PipedInputStream();
                final PipedOutputStream forParser = new PipedOutputStream(in);
                new Thread(new Runnable() {

                    public void run() {
                        try {
                            OutputStream out = SourceCache.startCaching(url);
                            InputStream is = url.openStream();
                            byte[] buffer = new byte[100000];
                            while (true) {
                                int amountRead = is.read(buffer);
                                if (amountRead == -1) {
                                    break;
                                }
                                forParser.write(buffer, 0, amountRead);
                                out.write(buffer, 0, amountRead);
                            }
                            forParser.close();
                            out.close();
                            SourceCache.finish(url);
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }).start();
                super.setIos(in);
            } catch (Exception e) {
                throw new ReadFailedException(e);
            }
            return super.read(set);
        } else {
            try {
                return SourceCache.get(url).read(set);
            } catch (IOException e) {
                throw new ReadFailedException(e);
            }
        }
    }
String chooseHGVersion(String version) {
        String line = "";
        try {
            URL connectURL = new URL("http://genome.ucsc.edu/cgi-bin/hgGateway?db=" + version);
            InputStream urlStream = connectURL.openStream();
            BufferedReader reader = new BufferedReader(new InputStreamReader(urlStream));
            while ((line = reader.readLine()) != null) {
                if (line.indexOf("hgsid") != -1) {
                    line = line.substring(line.indexOf("hgsid"));
                    line = line.substring(line.indexOf("VALUE=\"") + 7);
                    line = line.substring(0, line.indexOf("\""));
                    return line;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return line;
    }
public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    int index = lst.locationToIndex(e.getPoint());
                    try {
                        String location = (String) lst.getModel().getElementAt(index), refStr, startStr, stopStr;
                        if (location.indexOf("at chr") != -1) {
                            location = location.substring(location.indexOf("at ") + 3);
                            refStr = location.substring(0, location.indexOf(":"));
                            location = location.substring(location.indexOf(":") + 1);
                            startStr = location.substring(0, location.indexOf("-"));
                            stopStr = location.substring(location.indexOf("-") + 1);
                            moveViewer(refStr, Integer.parseInt(startStr), Integer.parseInt(stopStr));
                        } else {
                            String hgsid = chooseHGVersion(selPanel.dsn);
                            URL connectURL = new URL("http://genome.ucsc.edu/cgi-bin/hgTracks?hgsid=" + hgsid + "&position=" + location);
                            InputStream urlStream = connectURL.openStream();
                            BufferedReader reader = new BufferedReader(new InputStreamReader(urlStream));
                            readUCSCLocation(location, reader);
                        }
                    } catch (Exception exc) {
                        exc.printStackTrace();
                    }
                }
            }
public ActionForward dbExecute(ActionMapping pMapping, ActionForm pForm, HttpServletRequest pRequest, HttpServletResponse pResponse) throws DatabaseException {
        String email = pRequest.getParameter("email");
        MessageDigest md;
        try {
            md = MessageDigest.getInstance("SHA");
        } catch (NoSuchAlgorithmException e) {
            throw new DatabaseException("Could not hash password for storage: no such algorithm");
        }
        md.update(pRequest.getParameter("password").getBytes());
        String password = (new BASE64Encoder()).encode(md.digest());
        String remember = pRequest.getParameter("rememberLogin");
        User user = database.acquireUserByEmail(email);
        if (user == null || user.equals(User.anonymous()) || !user.getActive()) {
            return pMapping.findForward("invalid");
        } else if (user.getPassword().equals(password)) {
            pRequest.getSession().setAttribute("login", user);
            if (remember != null) {
                Cookie usercookie = new Cookie("bib.username", email);
                Cookie passcookie = new Cookie("bib.password", password.toString());
                usercookie.setPath("/");
                passcookie.setPath("/");
                usercookie.setMaxAge(60 * 60 * 24 * 365);
                passcookie.setMaxAge(60 * 60 * 24 * 365);
                pResponse.addCookie(usercookie);
                pResponse.addCookie(passcookie);
            }
            return pMapping.findForward("success");
        } else {
            return pMapping.findForward("invalid");
        }
    }
public List<String> makeQuery(String query) {
        List<String> result = new ArrayList<String>();
        try {
            query = URLUTF8Encoder.encode(query);
            URL url = new URL("http://ajax.googleapis.com/ajax/services/search/web?start=0&rsz=large&v=1.0&q=" + query);
            URLConnection connection = url.openConnection();
            connection.addRequestProperty("Referer", "http://poo.sk");
            String line;
            StringBuilder builder = new StringBuilder();
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            while ((line = reader.readLine()) != null) {
                builder.append(line);
            }
            String response = builder.toString();
            JSONObject json = new JSONObject(response);
            Long count = Long.decode(json.getJSONObject("responseData").getJSONObject("cursor").getString("estimatedResultCount"));
            LOG.info("Found " + count + " potential pages");
            JSONArray ja = json.getJSONObject("responseData").getJSONArray("results");
            for (int i = 0; i < ja.length(); i++) {
                JSONObject j = ja.getJSONObject(i);
                result.add(j.getString("url"));
            }
        } catch (Exception e) {
            LOG.error("Couldnt query Google for some reason check exception below");
            e.printStackTrace();
        }
        return result;
    }
public static final void main(String[] args) throws Exception {
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet httpget = new HttpGet("http://www.apache.org/");
        System.out.println("executing request " + httpget.getURI());
        HttpResponse response = httpclient.execute(httpget);
        System.out.println("----------------------------------------");
        System.out.println(response.getStatusLine());
        System.out.println("----------------------------------------");
        HttpEntity entity = response.getEntity();
        if (entity != null) {
            BufferedReader reader = new BufferedReader(new InputStreamReader(entity.getContent()));
            try {
                System.out.println(reader.readLine());
            } catch (IOException ex) {
                throw ex;
            } catch (RuntimeException ex) {
                httpget.abort();
                throw ex;
            } finally {
                reader.close();
            }
        }
    }
public static byte[] createAuthenticator(ByteBuffer data, String secret) {
        assert data.isDirect() == false : "must not a direct ByteBuffer";
        int pos = data.position();
        if (pos < RadiusPacket.MIN_PACKET_LENGTH) {
            System.err.println("packet too small");
            return null;
        }
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            byte[] arr = data.array();
            md5.reset();
            md5.update(arr, 0, pos);
            md5.update(secret.getBytes());
            return md5.digest();
        } catch (NoSuchAlgorithmException nsaex) {
            throw new RuntimeException("Could not access MD5 algorithm, fatal error");
        }
    }
public static Image getPluginImage(final Object plugin, final String name) {
        try {
            try {
                URL url = getPluginImageURL(plugin, name);
                if (m_URLImageMap.containsKey(url)) return m_URLImageMap.get(url);
                InputStream is = url.openStream();
                Image image;
                try {
                    image = getImage(is);
                    m_URLImageMap.put(url, image);
                } finally {
                    is.close();
                }
                return image;
            } catch (Throwable e) {
            }
        } catch (Throwable e) {
        }
        return null;
    }
private String generateServiceId(ObjectName mbeanName) {
        try {
            MessageDigest md5 = MessageDigest.getInstance("MD5");
            md5.update(mbeanName.toString().getBytes());
            StringBuffer hexString = new StringBuffer();
            byte[] digest = md5.digest();
            for (int i = 0; i < digest.length; i++) {
                hexString.append(Integer.toHexString(0xFF & digest[i]));
            }
            return hexString.toString().toUpperCase();
        } catch (Exception ex) {
            RuntimeException runTimeEx = new RuntimeException("Unexpected error during MD5 hash creation, check your JRE");
            runTimeEx.initCause(ex);
            throw runTimeEx;
        }
    }
private void addLocale(Locale locale) throws MissingResourceException {
        locale = stripVariant(locale);
        Map<String, String> props = localeToMap.get(locale);
        if (props == null) props = new HashMap<String, String>();
        String urlName = locale.toString() + LOCALE_FILE_URL_SUFFIX;
        URL url = ClassLoader.getSystemClassLoader().getResource(urlName);
        if (url == null) {
            url = Thread.currentThread().getContextClassLoader().getResource(urlName);
            if (url == null) {
                throw new MissingResourceException("Cannot locate hprops for " + "locale " + locale, "PropertiesLocalizer", "HProperties: for " + locale);
            }
        }
        BufferedReader input = null;
        try {
            input = new BufferedReader(new InputStreamReader((InputStream) url.openStream(), "UTF8"));
            String str;
            while ((str = input.readLine()) != null) {
                str = str.trim();
                if (!str.startsWith("#") && !str.startsWith("!")) {
                    int index = -1;
                    for (int i = 0; i < str.length(); i++) {
                        char c = str.charAt(i);
                        if (c == ':' || c == '=') {
                            index = i;
                            break;
                        }
                    }
                    if (index > 0) {
                        String key = str.substring(0, index).trim();
                        String value = str.substring(index + 1);
                        props.put(key, value);
                    }
                }
            }
        } catch (IOException ioe) {
            throw new MissingResourceException(ioe.getMessage(), "PropertiesLocalizer", "HProperties: for " + locale.toString());
        } finally {
            try {
                input.close();
            } catch (IOException ioe) {
            }
        }
        localeToMap.put(locale, props);
    }
public void run() throws Exception {
        logger.debug("#run enter");
        PreparedStatement ps = null;
        try {
            connection.setAutoCommit(false);
            ps = connection.prepareStatement(SQL_UPDATE_ITEM_MIN_QTTY);
            ps.setInt(1, deliveryId);
            ps.setInt(2, deliveryId);
            ps.executeUpdate();
            ps.close();
            logger.debug("#run update STORE.ITEM ok");
            ps = connection.prepareStatement(SQL_DELETE_DELIVERY_LINE);
            ps.setInt(1, deliveryId);
            ps.executeUpdate();
            ps.close();
            logger.debug("#run delete STORE.DELIVERY_LINE ok");
            ps = connection.prepareStatement(SQL_DELETE_DELIVERY);
            ps.setInt(1, deliveryId);
            ps.executeUpdate();
            ps.close();
            logger.debug("#run delete STORE.DELIVERY ok");
            connection.commit();
        } catch (Exception ex) {
            logger.error("#run Transaction roll back ", ex);
            connection.rollback();
            throw new Exception("#run Не удалось загрузить в БД информацию об обновлении склада. Ошибка : " + ex.getMessage());
        } finally {
            connection.setAutoCommit(true);
        }
        logger.debug("#run exit");
    }