semeru/Code-Code-CloneDetection-BigCloneBench huggingface dataset:
public static String md5encrypt(String toEncrypt) {
        if (toEncrypt == null) {
            throw new IllegalArgumentException("null is not a valid password to encrypt");
        }
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            md.update(toEncrypt.getBytes());
            byte[] hash = md.digest();
            return new String(dumpBytes(hash));
        } catch (NoSuchAlgorithmException nsae) {
            return toEncrypt;
        }
    }
@Override
    public void sendContent(OutputStream out, Range range, Map<String, String> params, String contentType) throws IOException, NotAuthorizedException, BadRequestException, NotFoundException {
        try {
            resolveFileAttachment();
        } catch (NoFileByTheIdException e) {
            throw new NotFoundException(e.getLocalizedMessage());
        }
        DefinableEntity owningEntity = fa.getOwner().getEntity();
        InputStream in = getFileModule().readFile(owningEntity.getParentBinder(), owningEntity, fa);
        try {
            if (range != null) {
                if (logger.isDebugEnabled()) logger.debug("sendContent: ranged content: " + toString(fa));
                PartialGetHelper.writeRange(in, range, out);
            } else {
                if (logger.isDebugEnabled()) logger.debug("sendContent: send whole file " + toString(fa));
                IOUtils.copy(in, out);
            }
            out.flush();
        } catch (ReadingException e) {
            throw new IOException(e);
        } catch (WritingException e) {
            throw new IOException(e);
        } finally {
            IOUtils.closeQuietly(in);
        }
    }
public void transform(String style, String spec, OutputStream out) throws IOException {
        URL url = new URL(rootURL, spec);
        InputStream in = new PatchXMLSymbolsStream(new StripDoctypeStream(url.openStream()));
        transform(style, in, out);
        in.close();
    }
public int addLocationInfo(int id, double lattitude, double longitude) {
        int ret = 0;
        Connection conn = null;
        PreparedStatement psmt = null;
        try {
            String sql = "insert into kddb.location_info (user_id, latitude, longitude) values(?, ?, ?)";
            conn = getConnection();
            psmt = conn.prepareStatement(sql);
            psmt.setInt(1, id);
            psmt.setDouble(2, lattitude);
            psmt.setDouble(3, longitude);
            ret = psmt.executeUpdate();
            if (ret == 1) {
                conn.commit();
            } else {
                conn.rollback();
            }
        } catch (SQLException ex) {
            log.error("[addLocationInfo]", ex);
        } finally {
            endProsess(conn, psmt, null, null);
        }
        return ret;
    }
public String getScore(int id) {
        String title = null;
        try {
            URL url = new URL(BASE_URL + id + ".html");
            BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
            String line;
            while ((line = reader.readLine()) != null) {
                if (line.contains("<title>")) {
                    title = line.substring(line.indexOf("<title>") + 7, line.indexOf("</title>"));
                    title = title.substring(0, title.indexOf("|")).trim();
                    break;
                }
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return title;
    }
public String getMatches() {
        StringBuilder builder = new StringBuilder("");
        try {
            URL url = new URL(LIVE_SCORE_URL);
            BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
            String inputLine;
            while ((inputLine = in.readLine()) != null) {
                builder.append(inputLine);
            }
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return builder.toString();
    }
public Vector<String> getNetworkServersIPs(String netaddress) {
        Vector<String> result = new Vector<String>();
        boolean serverline = false;
        String line;
        String[] splitline;
        try {
            URL url = new URL(netaddress);
            URLConnection connection = url.openConnection();
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            while ((line = reader.readLine()) != null) {
                if ((serverline) && line.startsWith(";")) {
                    serverline = false;
                }
                if (serverline) {
                    splitline = line.split(":");
                    result.add(splitline[1]);
                }
                if (line.startsWith("!SERVERS")) {
                    serverline = true;
                }
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;
    }
public Vector<String> getVoiceServersNames() {
        Vector<String> result = new Vector<String>();
        boolean serverline = false;
        String line;
        String[] splitline;
        try {
            URL url = new URL(voiceaddress);
            URLConnection connection = url.openConnection();
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            while ((line = reader.readLine()) != null) {
                if (serverline) {
                    splitline = line.split(":");
                    result.add(splitline[0]);
                }
                if (line.startsWith("!VOICE SERVERS")) {
                    serverline = true;
                }
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return result;
    }
public String GetMemberName(String id) {
        String name = null;
        try {
            String line;
            URL url = new URL(intvasmemberDeatails + "?CID=" + id);
            URLConnection connection = url.openConnection();
            BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            while ((line = reader.readLine()) != null) {
                name = line;
            }
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        String[] parts = name.split(" ");
        rating = parts[2];
        return parts[0] + " " + parts[1];
    }
private BufferedImage _getImage(String urlStr) throws IOException {
        URL url = new URL(urlStr);
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();
        conn.connect();
        InputStream in = null;
        try {
            in = conn.getInputStream();
            return ImageIO.read(in);
        } finally {
            IOUtilities.close(in);
        }
    }
public static final synchronized String hash(String data) {
        if (digest == null) {
            try {
                digest = MessageDigest.getInstance("MD5");
            } catch (NoSuchAlgorithmException nsae) {
                System.err.println("Failed to load the MD5 MessageDigest. " + "unable to function normally.");
                nsae.printStackTrace();
            }
        }
        digest.update(data.getBytes());
        return encodeHex(digest.digest());
    }
private void impurlActionPerformed(java.awt.event.ActionEvent evt) {
        try {
            String prevurl = Prefs.getPref(PrefName.LASTIMPURL);
            String urlst = JOptionPane.showInputDialog(Resource.getResourceString("enturl"), prevurl);
            if (urlst == null || urlst.equals("")) return;
            Prefs.putPref(PrefName.LASTIMPURL, urlst);
            URL url = new URL(urlst);
            impURLCommon(urlst, url.openStream());
        } catch (Exception e) {
            Errmsg.errmsg(e);
        }
    }
public String getHtmlPage(URL url) {
        String html = null;
        try {
            BufferedReader br = new BufferedReader(new InputStreamReader(url.openConnection().getInputStream()));
            StringBuffer sb = new StringBuffer();
            String line;
            while ((line = br.readLine()) != null) {
                sb.append(line).append("\n");
            }
            br.close();
            html = sb.toString().replaceAll(HTML_FILTER_RE, " ");
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return html;
    }
public Document getSdlDomResource(String aResourceName) throws SdlException {
        InputStream in = null;
        try {
            URL url = getDeploymentContext().getResourceURL(aResourceName);
            if (url == null) {
                return null;
            } else {
                in = url.openStream();
                return getSdlParser().loadSdlDocument(in, null);
            }
        } catch (Throwable t) {
            logger.error("Error: unable to load: " + aResourceName + " from " + getDeploymentContext().getDeploymentLocation());
            throw new SdlDeploymentException(MessageFormat.format("unable to load: {0} from {1}", new Object[] { aResourceName, getDeploymentContext().getDeploymentLocation() }), t);
        } finally {
            SdlCloser.close(in);
        }
    }
public Document getWsdlDomResource(String aResourceName) throws SdlException {
        logger.debug("getWsdlDomResource() " + aResourceName);
        InputStream in = null;
        try {
            URL url = getDeploymentContext().getResourceURL(aResourceName);
            if (url == null) {
                logger.error("url is null");
                return null;
            } else {
                logger.debug("loading wsdl document " + aResourceName);
                in = url.openStream();
                return getSdlParser().loadWsdlDocument(in, null);
            }
        } catch (Throwable t) {
            logger.error("Error: " + t + " for " + aResourceName);
            throw new SdlDeploymentException(MessageFormat.format("unable to load: {0} from {1}", new Object[] { aResourceName, getDeploymentContext().getDeploymentLocation() }), t);
        } finally {
            SdlCloser.close(in);
        }
    }
public static String encrypt(String password) {
        try {
            MessageDigest digest = MessageDigest.getInstance("SHA-256");
            digest.update(password.getBytes());
            BASE64Encoder encoder = new BASE64Encoder();
            return encoder.encode(digest.digest());
        } catch (NoSuchAlgorithmException ns) {
            ns.printStackTrace();
            return password;
        }
    }
public static final boolean compressToZip(final String sSource, final String sDest, final boolean bDeleteSourceOnSuccess) {
        ZipOutputStream os = null;
        InputStream is = null;
        try {
            os = new ZipOutputStream(new FileOutputStream(sDest));
            is = new FileInputStream(sSource);
            final byte[] buff = new byte[1024];
            int r;
            String sFileName = sSource;
            if (sFileName.indexOf('/') >= 0) sFileName = sFileName.substring(sFileName.lastIndexOf('/') + 1);
            os.putNextEntry(new ZipEntry(sFileName));
            while ((r = is.read(buff)) > 0) os.write(buff, 0, r);
            is.close();
            os.flush();
            os.closeEntry();
            os.close();
        } catch (Throwable e) {
            Log.log(Log.WARNING, "lazyj.Utils", "compressToZip : cannot compress '" + sSource + "' to '" + sDest + "' because", e);
            return false;
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException ioe) {
                }
            }
            if (os != null) {
                try {
                    os.close();
                } catch (IOException ioe) {
                }
            }
        }
        if (bDeleteSourceOnSuccess) try {
            if (!(new File(sSource)).delete()) Log.log(Log.WARNING, "lazyj.Utils", "compressToZip: could not delete original file (" + sSource + ")");
        } catch (SecurityException se) {
            Log.log(Log.ERROR, "lazyj.Utils", "compressToZip: security constraints prevents file deletion");
        }
        return true;
    }
public void runDynusT() {
        final String[] exeFiles = new String[] { "DynusT.exe", "DLL_ramp.dll", "Ramp_Meter_Fixed_CDLL.dll", "Ramp_Meter_Feedback_CDLL.dll", "Ramp_Meter_Feedback_FDLL.dll", "libifcoremd.dll", "libmmd.dll", "Ramp_Meter_Fixed_FDLL.dll", "libiomp5md.dll" };
        final String[] modelFiles = new String[] { "network.dat", "scenario.dat", "control.dat", "ramp.dat", "incident.dat", "movement.dat", "vms.dat", "origin.dat", "destination.dat", "StopCap4Way.dat", "StopCap2Way.dat", "YieldCap.dat", "WorkZone.dat", "GradeLengthPCE.dat", "leftcap.dat", "system.dat", "output_option.dat", "bg_demand_adjust.dat", "xy.dat", "TrafficFlowModel.dat", "parameter.dat" };
        log.info("Creating iteration-directory...");
        File iterDir = new File(this.tmpDir);
        if (!iterDir.exists()) {
            iterDir.mkdir();
        }
        log.info("Copying application files to iteration-directory...");
        for (String filename : exeFiles) {
            log.info("  Copying " + filename);
            IOUtils.copyFile(new File(this.dynusTDir + "/" + filename), new File(this.tmpDir + "/" + filename));
        }
        log.info("Copying model files to iteration-directory...");
        for (String filename : modelFiles) {
            log.info("  Copying " + filename);
            IOUtils.copyFile(new File(this.modelDir + "/" + filename), new File(this.tmpDir + "/" + filename));
        }
        String logfileName = this.tmpDir + "/dynus-t.log";
        String cmd = this.tmpDir + "/DynusT.exe";
        log.info("running command: " + cmd);
        int timeout = 14400;
        int exitcode = ExeRunner.run(cmd, logfileName, timeout);
        if (exitcode != 0) {
            throw new RuntimeException("There was a problem running Dynus-T. exit code: " + exitcode);
        }
    }
private void translate(String sender, String message) {
        StringTokenizer st = new StringTokenizer(message, " ");
        message = message.replaceFirst(st.nextToken(), "");
        String typeCode = st.nextToken();
        message = message.replaceFirst(typeCode, "");
        try {
            String data = URLEncoder.encode(message, "UTF-8");
            URL url = new URL("http://babelfish.altavista.com/babelfish/tr?doit=done&urltext=" + data + "&lp=" + typeCode);
            URLConnection conn = url.openConnection();
            conn.setDoOutput(true);
            OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
            wr.write(data);
            wr.flush();
            BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String line;
            while ((line = rd.readLine()) != null) {
                if (line.contains("input type=hidden name=\"q\"")) {
                    String[] tokens = line.split("\"");
                    sendMessage(sender, tokens[3]);
                }
            }
            wr.close();
            rd.close();
        } catch (Exception e) {
        }
    }
public static void fileUpload() throws IOException {
        HttpClient httpclient = new DefaultHttpClient();
        httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
        HttpPost httppost = new HttpPost(postURL);
        File file = new File("d:/hai.html");
        System.out.println(ukeycookie);
        httppost.setHeader("Cookie", ukeycookie + ";" + skeycookie + ";" + usercookie);
        MultipartEntity mpEntity = new MultipartEntity();
        ContentBody cbFile = new FileBody(file);
        mpEntity.addPart("", cbFile);
        httppost.setEntity(mpEntity);
        System.out.println("Now uploading your file into mediafire...........................");
        HttpResponse response = httpclient.execute(httppost);
        HttpEntity resEntity = response.getEntity();
        System.out.println(response.getStatusLine());
        if (resEntity != null) {
            System.out.println("Getting upload response key value..........");
            uploadresponsekey = EntityUtils.toString(resEntity);
            getUploadResponseKey();
            System.out.println("upload resoponse key " + uploadresponsekey);
        }
    }
private void copy(URL url, IFile file, IProgressMonitor monitor) throws CoreException, IOException {
            InputStream input = null;
            try {
                input = url.openStream();
                if (file.exists()) {
                    file.setContents(input, IResource.FORCE, monitor);
                } else {
                    file.create(input, IResource.FORCE, monitor);
                }
            } finally {
                if (input != null) {
                    try {
                        input.close();
                    } catch (IOException ignore) {
                    }
                }
            }
        }
private String readJsonString() {
        StringBuilder builder = new StringBuilder();
        HttpClient client = new DefaultHttpClient();
        HttpGet httpGet = new HttpGet(SERVER_URL);
        try {
            HttpResponse response = client.execute(httpGet);
            StatusLine statusLine = response.getStatusLine();
            int statusCode = statusLine.getStatusCode();
            if (statusCode == 200) {
                HttpEntity entity = response.getEntity();
                InputStream content = entity.getContent();
                BufferedReader reader = new BufferedReader(new InputStreamReader(content));
                String line;
                while ((line = reader.readLine()) != null) {
                    builder.append(line);
                }
            } else {
                Log.e(TAG, "Failed to download file");
            }
        } catch (ClientProtocolException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return builder.toString();
    }
public void test5() {
        try {
            SocketAddress proxyAddress = new InetSocketAddress("127.0.0.1", 8080);
            Proxy proxy = new Proxy(Type.HTTP, proxyAddress);
            URL url = new URL("http://woodstock.net.br:8443");
            URLConnection connection = url.openConnection(proxy);
            InputStream inputStream = connection.getInputStream();
            Scanner scanner = new Scanner(inputStream);
            while (scanner.hasNextLine()) {
                System.out.println(scanner.nextLine());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
public OutputStream getOutputStream() throws IOException {
        try {
            URL url = getURL();
            URLConnection urlc = url.openConnection();
            return urlc.getOutputStream();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
public InputStream getFtpInputStream() throws IOException {
        try {
            URL url = getURL();
            URLConnection urlc = url.openConnection();
            return urlc.getInputStream();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
public static String getHash(String text) {
        try {
            MessageDigest md = MessageDigest.getInstance("SHA-1");
            md.update(text.getBytes());
            byte[] array = md.digest();
            StringBuffer sb = new StringBuffer();
            for (int i = 0; i < array.length; i++) {
                sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100));
            }
            return sb.toString();
        } catch (NoSuchAlgorithmException ex) {
            Logger.getLogger(User.class.getName()).log(Level.SEVERE, null, ex);
            return null;
        }
    }
final void saveProject(Project project, final File file) {
        if (projectsList.contains(project)) {
            if (project.isDirty() || !file.getParentFile().equals(workspaceDirectory)) {
                try {
                    if (!file.exists()) {
                        if (!file.createNewFile()) throw new IOException("cannot create file " + file.getAbsolutePath());
                    }
                    File tmpFile = File.createTempFile("JFPSM", ".tmp");
                    ZipOutputStream zoStream = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(file)));
                    zoStream.setMethod(ZipOutputStream.DEFLATED);
                    ZipEntry projectXMLEntry = new ZipEntry("project.xml");
                    projectXMLEntry.setMethod(ZipEntry.DEFLATED);
                    zoStream.putNextEntry(projectXMLEntry);
                    CustomXMLEncoder encoder = new CustomXMLEncoder(new BufferedOutputStream(new FileOutputStream(tmpFile)));
                    encoder.writeObject(project);
                    encoder.close();
                    int bytesIn;
                    byte[] readBuffer = new byte[1024];
                    FileInputStream fis = new FileInputStream(tmpFile);
                    while ((bytesIn = fis.read(readBuffer)) != -1) zoStream.write(readBuffer, 0, bytesIn);
                    fis.close();
                    ZipEntry entry;
                    String floorDirectory;
                    for (FloorSet floorSet : project.getLevelSet().getFloorSetsList()) for (Floor floor : floorSet.getFloorsList()) {
                        floorDirectory = "levelset/" + floorSet.getName() + "/" + floor.getName() + "/";
                        for (MapType type : MapType.values()) {
                            entry = new ZipEntry(floorDirectory + type.getFilename());
                            entry.setMethod(ZipEntry.DEFLATED);
                            zoStream.putNextEntry(entry);
                            ImageIO.write(floor.getMap(type).getImage(), "png", zoStream);
                        }
                    }
                    final String tileDirectory = "tileset/";
                    for (Tile tile : project.getTileSet().getTilesList()) for (int textureIndex = 0; textureIndex < tile.getMaxTextureCount(); textureIndex++) if (tile.getTexture(textureIndex) != null) {
                        entry = new ZipEntry(tileDirectory + tile.getName() + textureIndex + ".png");
                        entry.setMethod(ZipEntry.DEFLATED);
                        zoStream.putNextEntry(entry);
                        ImageIO.write(tile.getTexture(textureIndex), "png", zoStream);
                    }
                    zoStream.close();
                    tmpFile.delete();
                } catch (IOException ioe) {
                    throw new RuntimeException("The project " + project.getName() + " cannot be saved!", ioe);
                }
            }
        } else throw new IllegalArgumentException("The project " + project.getName() + " is not handled by this project set!");
    }