id int32 0 901k | id1 int32 74 23.7M | id2 int32 74 23.7M | func1 stringlengths 234 68.5k | func2 stringlengths 234 68.5k | label bool 2
classes |
|---|---|---|---|---|---|
1,300 | 3,788,596 | 13,292,295 | public static boolean copyFile(final File fileFrom, final File fileTo) {
assert fileFrom != null : "fileFrom is null";
assert fileTo != null : "fileTo is null";
LOGGER.info(buildLogString(COPY_FILE_INFO, new Object[] { fileFrom, fileTo }));
boolean error = true;
FileInputStre... | public static void copyURLToFile(URL source, File destination) throws IOException {
InputStream input = source.openStream();
try {
FileOutputStream output = openOutputStream(destination);
try {
IOUtils.copy(input, output);
} finally {
... | true |
1,301 | 11,723,383 | 5,258,165 | private void getImage(String filename) throws MalformedURLException, IOException, SAXException, FileNotFoundException {
String url = Constants.STRATEGICDOMINATION_URL + "/images/gameimages/" + filename;
WebRequest req = new GetMethodWebRequest(url);
SiteResponse response = getSiteResponse(re... | private static boolean copyFile(File src, File dest) {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(src);
fos = new FileOutputStream(dest);
for (int c = fis.read(); c != -1; c = fis.read()) fos.write(c);
... | true |
1,302 | 19,172,809 | 2,915,107 | public static Document parseDocument(Object toParse, boolean isFile, List<ErrorMessage> errorMessages) {
Document document = null;
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setValidating(true);
docBuil... | public static void unZip(String unZipfileName, String outputDirectory) throws IOException, FileNotFoundException {
FileOutputStream fileOut;
File file;
ZipEntry zipEntry;
ZipInputStream zipIn = new ZipInputStream(new BufferedInputStream(new FileInputStream(unZipfileName)), encoder);
... | false |
1,303 | 3,239,919 | 5,174,084 | public static byte[] getHashedPassword(String password, byte[] randomBytes) {
byte[] hashedPassword = null;
try {
MessageDigest messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(randomBytes);
messageDigest.update(password.getBytes("UTF-8"));
... | public static String sha1Hash(String input) {
try {
MessageDigest sha1Digest = MessageDigest.getInstance("SHA-1");
sha1Digest.update(input.getBytes());
return byteArrayToString(sha1Digest.digest());
} catch (Exception e) {
logger.error(e.getMessage(), ... | true |
1,304 | 967,161 | 11,504,871 | private static FacesBean.Type _createType() {
try {
ClassLoader cl = _getClassLoader();
URL url = cl.getResource("META-INF/faces-bean-type.properties");
if (url != null) {
Properties properties = new Properties();
InputStream is = url.openS... | public static String encrypt(String password) throws NoSuchAlgorithmException {
java.security.MessageDigest d = null;
d = java.security.MessageDigest.getInstance("MD5");
d.reset();
d.update(password.getBytes());
byte[] cr = d.digest();
return getString(cr).toLowerCase... | false |
1,305 | 12,754,505 | 5,402,254 | public static final String MD5(String value) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(value.getBytes());
BigInteger hash = new BigInteger(1, md.digest());
String newValue = hash.toString(16);
return newValue;
}... | public void setKey(String key) {
MessageDigest md5;
byte[] mdKey = new byte[32];
try {
md5 = MessageDigest.getInstance("MD5");
md5.update(key.getBytes());
byte[] digest = md5.digest();
System.arraycopy(digest, 0, mdKey, 0, 16);
Syst... | true |
1,306 | 16,714,944 | 9,901,451 | public static String MD5(String text) throws ProducteevSignatureException {
try {
MessageDigest md;
md = MessageDigest.getInstance(ALGORITHM);
byte[] md5hash;
md.update(text.getBytes("utf-8"), 0, text.length());
md5hash = md.digest();
r... | protected String readUrl(String urlString) throws IOException {
URL url = new URL(urlString);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String response = "";
String inputLine;
while ((inputLine = in.readLine()) != null) response += input... | false |
1,307 | 13,825,969 | 11,776,522 | @Override
protected void doFetch(HttpServletRequest request, HttpServletResponse response) throws IOException, GadgetException {
if (request.getHeader("If-Modified-Since") != null) {
response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
return;
}
String host = ... | protected File getFile(NameCategory category) throws IOException {
File home = new File(System.getProperty("user.dir"));
String fileName = String.format("%s.txt", category);
File file = new File(home, fileName);
if (file.exists()) {
return file;
} else {
... | true |
1,308 | 19,963,744 | 7,577,030 | public void atualizarLivro(LivroBean livro) {
PreparedStatement pstmt = null;
String sql = "update livro " + "set " + "isbn = ?, " + "autor = ?, " + "editora = ?, " + "edicao = ?, " + "titulo = ? " + "where " + "isbn = ?";
try {
pstmt = connection.prepareStatement(sql);
... | private void zipFiles(File file, File[] fa) throws Exception {
File f = new File(file, ALL_FILES_NAME);
if (f.exists()) {
f.delete();
f = new File(file, ALL_FILES_NAME);
}
ZipOutputStream zoutstrm = new ZipOutputStream(new FileOutputStream(f));
for (in... | false |
1,309 | 20,514,481 | 16,360,226 | public static File copy(String fromFileName, String toFileName) throws IOException {
File fromFile = new File(fromFileName);
File toFile = new File(toFileName);
System.out.println("AbsolutePath fromFile: " + fromFile.getAbsolutePath());
System.out.println("AbsolutePath toFile: " + to... | public static void main(String[] args) {
if (args.length < 1) {
System.out.println("Parameters: method arg1 arg2 arg3 etc");
System.out.println("");
System.out.println("Methods:");
System.out.println(" reloadpolicies");
System.out.println(" ... | true |
1,310 | 17,052,257 | 4,672,830 | public static String encriptar(String string) throws Exception {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
throw new Exception("Algoritmo de Criptografia não encontrado... | public static byte[] readFile(String filePath) throws IOException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
FileInputStream is = new FileInputStream(filePath);
try {
IOUtils.copy(is, os);
return os.toByteArray();
} finally {
is.clos... | false |
1,311 | 3,463,984 | 12,021,779 | @Override
public InputStream getResourceStream(final String arg0) throws ResourceNotFoundException {
try {
final ServletContext context = CContext.getInstance().getContext();
final URL url = context.getResource(arg0);
return url.openStream();
... | private void insert() throws SQLException, NamingException {
Logger logger = getLogger();
if (logger.isDebugEnabled()) {
logger.debug("enter - " + getClass().getName() + ".insert()");
}
try {
if (logger.isInfoEnabled()) {
logger.info("insert():... | false |
1,312 | 6,387,775 | 11,021,107 | public static String hashSHA1(String value) {
try {
MessageDigest digest = MessageDigest.getInstance("SHA-1");
digest.update(value.getBytes());
BigInteger hash = new BigInteger(1, digest.digest());
return hash.toString(16);
} catch (NoSuchAlgorithmExce... | private String getResourceAsString(final String name) throws IOException {
final InputStream is = JiBXTestCase.class.getResourceAsStream(name);
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
IOUtils.copyAndClose(is, baos);
return baos.toString();
}
| false |
1,313 | 3,558,514 | 18,542,300 | private synchronized void ensureParsed() throws IOException, BadIMSCPException {
if (cp != null) return;
if (on_disk == null) {
on_disk = createTemporaryFile();
OutputStream to_disk = new FileOutputStream(on_disk);
IOUtils.copy(in.getInputStream(), to_disk);
... | public static void copy(File src, File dest) throws IOException {
FileChannel srcChannel = new FileInputStream(src).getChannel();
FileChannel destChannel = new FileOutputStream(dest).getChannel();
destChannel.transferFrom(srcChannel, 0, srcChannel.size());
srcChannel.close();
... | true |
1,314 | 3,803,030 | 11,277,510 | public static String getRolesString(HttpServletRequest hrequest, HttpServletResponse hresponse, String username, String servicekey) {
String registerapp = SSOFilter.getRegisterapp();
String u = SSOUtil.addParameter(registerapp + "/api/getroles", "username", username);
u = SSOUtil.addParamete... | private void channelCopy(File source, File dest) throws IOException {
FileChannel srcChannel = new FileInputStream(source).getChannel();
FileChannel dstChannel = new FileOutputStream(dest).getChannel();
try {
dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
} fi... | false |
1,315 | 606,859 | 9,186,582 | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | private static void unzipEntry(ZipFile zipfile, ZipEntry entry, File outputDir) throws IOException {
if (entry.isDirectory()) {
createDir(new File(outputDir, entry.getName()));
return;
}
File outputFile = new File(outputDir, entry.getName());
if (!outputFile.g... | true |
1,316 | 10,933,932 | 4,928,350 | public static String crypt(String str) {
if (str == null || str.length() == 0) {
throw new IllegalArgumentException("String to encript cannot be null or zero length");
}
StringBuffer hexString = new StringBuffer();
MessageDigest md = null;
try {
md = M... | private static String getBase64(String text, String algorithm) throws NoSuchAlgorithmException {
AssertUtility.notNull(text);
AssertUtility.notNullAndNotSpace(algorithm);
String base64;
MessageDigest md = MessageDigest.getInstance(algorithm);
md.update(text.getBytes());
... | true |
1,317 | 21,485,699 | 12,067,823 | public static Debugger getDebugger(InetAddress host, int port, String password) throws IOException {
try {
Socket s = new Socket(host, port);
try {
ObjectOutputStream out = new ObjectOutputStream(s.getOutputStream());
ObjectInputStream in = new ObjectI... | public void run() {
if (saveAsDialog == null) {
saveAsDialog = new FileDialog(window.getShell(), SWT.SAVE);
saveAsDialog.setFilterExtensions(saveAsTypes);
}
String outputFile = saveAsDialog.open();
if (outputFile != null) {
Object inputFile = DataS... | false |
1,318 | 20,822,727 | 241,286 | private static void copyFile(String fromFile, String toFile) throws Exception {
FileInputStream from = null;
FileOutputStream to = null;
try {
from = new FileInputStream(fromFile);
to = new FileOutputStream(toFile);
byte[] buffer = new byte[4096];
... | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | true |
1,319 | 4,921,634 | 10,329,098 | public int update(BusinessObject o) throws DAOException {
int update = 0;
Item item = (Item) o;
try {
PreparedStatement pst = connection.prepareStatement(XMLGetQuery.getQuery("UPDATE_ITEM"));
pst.setString(1, item.getDescription());
pst.setDouble(2, item.g... | public void setPilot(PilotData pilotData) throws UsernameNotValidException {
try {
if (pilotData.username.trim().equals("") || pilotData.password.trim().equals("")) throw new UsernameNotValidException(1, "Username or password missing");
PreparedStatement psta;
if (pilotDa... | true |
1,320 | 9,713,536 | 15,376,869 | @SuppressWarnings("unchecked")
private void doService(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
final String url = request.getRequestURL().toString();
if (url.endsWith("/favicon.ico")) {
response.setStatus(HttpServlet... | public static void writeToFile(final File file, final InputStream in) throws IOException {
IOUtils.createFile(file);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
IOUtils.copyStream(in, fos);
} finally {
IOUtils.closeIO(fos);... | true |
1,321 | 606,859 | 11,103,539 | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | public void compressFile(String filePath) {
String outPut = filePath + ".zip";
try {
FileInputStream in = new FileInputStream(filePath);
GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(outPut));
byte[] buffer = new byte[4096];
int byte... | true |
1,322 | 20,559,733 | 18,956,180 | public Long addPortletName(PortletNameBean portletNameBean) {
PreparedStatement ps = null;
DatabaseAdapter dbDyn = null;
try {
dbDyn = DatabaseAdapter.getInstance();
CustomSequenceType seq = new CustomSequenceType();
seq.setSequenceName("seq_WM_PORTAL_PORT... | private void copyMerge(Path[] sources, OutputStream out) throws IOException {
Configuration conf = getConf();
for (int i = 0; i < sources.length; ++i) {
FileSystem fs = sources[i].getFileSystem(conf);
InputStream in = fs.open(sources[i]);
try {
IOU... | false |
1,323 | 2,676,364 | 5,021,571 | public void reset(String componentName, int currentPilot) {
try {
PreparedStatement psta = jdbc.prepareStatement("DELETE FROM component_prop " + "WHERE pilot_id = ? " + "AND component_name = ?");
psta.setInt(1, currentPilot);
psta.setString(2, componentName);
... | public void registerSchema(String newSchemaName, String objectControlller, long boui, String expression, String schema) throws SQLException {
Connection cndef = null;
PreparedStatement pstm = null;
try {
cndef = this.getRepositoryConnection(p_ctx.getApplication(), "default", 2);
... | true |
1,324 | 13,744,886 | 9,689,565 | @Override
public void run() {
try {
FileChannel in = new FileInputStream(inputfile).getChannel();
long pos = 0;
for (int i = 1; i <= noofparts; i++) {
FileChannel out = new FileOutputStream(outputfile.getAbsolutePath() + "." + "v" + i).getChannel();
... | public static String md5sum(String s, String alg) {
try {
MessageDigest md = MessageDigest.getInstance(alg);
md.update(s.getBytes(), 0, s.length());
StringBuffer sb = new StringBuffer();
synchronized (sb) {
for (byte b : md.digest()) sb.append(... | false |
1,325 | 12,883,277 | 6,085,930 | private void createWikiPages(WikiContext context) throws PluginException {
OntologyWikiPageName owpn = new OntologyWikiPageName(omemo.getFormDataAlias().toUpperCase(), omemo.getFormDataVersionDate());
String wikiPageFullFileName = WikiPageName2FullFileName(context, owpn.toString());
String r... | public void update() {
if (!updatable) {
Main.fenetre().erreur(Fenetre.OLD_VERSION);
return;
}
try {
Main.fenetre().update();
Element remoteRoot = new SAXBuilder().build(xml).getRootElement();
addPackages = new HashMap<Integer, Pack... | true |
1,326 | 12,120,684 | 18,657,526 | private void getRandomGUID(boolean secure) {
MessageDigest md5;
StringBuilder sbValueBeforeHash = new StringBuilder();
try {
md5 = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
throw new ApplicationIllegalArgumentException(e);
... | public void visit(AuthenticationMD5Password message) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(((String) properties.get("password") + (String) properties.get("user")).getBytes("iso8859-1"));
String newValue = toHexString(md5.digest()) + new ... | true |
1,327 | 4,501,770 | 10,288,424 | protected final void connectFtp() throws IOException {
try {
if (!this.ftpClient.isConnected()) {
this.ftpClient.connect(getHost(), getPort());
getLog().write(Level.INFO, String.format(getMessages().getString("FtpSuccessfullyConnected"), getHos... | public static String encrypt(String x) throws Exception {
MessageDigest mdEnc = MessageDigest.getInstance("SHA-1");
mdEnc.update(x.getBytes(), 0, x.length());
String md5 = new BigInteger(1, mdEnc.digest()).toString(16);
return md5;
}
| false |
1,328 | 11,149,084 | 18,477,922 | private void deleteProject(String uid, String home, HttpServletRequest request, HttpServletResponse response) throws Exception {
String project = request.getParameter("project");
String line;
response.setContentType("text/html");
PrintWriter out = response.getWriter();
htmlHe... | @Override
public void run() {
String lastVersion = null;
try {
URL projectSite = new URL("http://code.google.com/p/g15lastfm/");
URLConnection urlC = projectSite.openConnection();
BufferedReader in = new ... | false |
1,329 | 8,407,905 | 241,286 | private void copyResources(File oggDecDir, String[] resources, String resPrefix) throws FileNotFoundException, IOException {
for (int i = 0; i < resources.length; i++) {
String res = resPrefix + resources[i];
InputStream is = this.getClass().getResourceAsStream(res);
if (... | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | true |
1,330 | 3,820,224 | 5,467,376 | private String hashString(String key) {
MessageDigest digest;
try {
digest = java.security.MessageDigest.getInstance("MD5");
digest.update(key.getBytes());
byte[] hash = digest.digest();
BigInteger bi = new BigInteger(1, hash);
return Strin... | protected boolean check(String username, String password, String realm, String nonce, String nc, String cnonce, String qop, String uri, String response, HttpServletRequest request) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(username.getBytes());
... | true |
1,331 | 10,062,077 | 78,966 | 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... | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | true |
1,332 | 811,157 | 11,370,967 | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | public void copyFile(File in, File out) throws Exception {
FileChannel ic = new FileInputStream(in).getChannel();
FileChannel oc = new FileOutputStream(out).getChannel();
ic.transferTo(0, ic.size(), oc);
ic.close();
oc.close();
}
| true |
1,333 | 922,476 | 6,298,465 | public void convert(File src, File dest) throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(src));
DcmParser p = pfact.newDcmParser(in);
Dataset ds = fact.newDataset();
p.setDcmHandler(ds.getDcmHandler());
try {
FileFormat format = p... | public static void copyFile(File in, File out) throws IOException {
FileChannel inChannel = new FileInputStream(in).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
try {
if (System.getProperty("os.name").toUpperCase().indexOf("WIN") != -1) {
... | true |
1,334 | 2,963,526 | 16,762,677 | public static void write(File file, InputStream source) throws IOException {
OutputStream outputStream = null;
assert file != null : "file must not be null.";
assert file.isFile() : "file must be a file.";
assert file.canWrite() : "file must be writable.";
assert source != nu... | public static void copyFile(File src, File dest) throws IOException {
FileInputStream fIn;
FileOutputStream fOut;
FileChannel fIChan, fOChan;
long fSize;
MappedByteBuffer mBuf;
fIn = new FileInputStream(src);
fOut = new FileOutputStream(dest);
fIChan =... | true |
1,335 | 10,228,411 | 8,930,241 | public File createReadmeFile(File dir, MavenProject mavenProject) throws IOException {
InputStream is = getClass().getResourceAsStream("README.template");
StringWriter sw = new StringWriter();
IOUtils.copy(is, sw);
String content = sw.getBuffer().toString();
content = StringU... | public UserAgentContext getUserAgentContext() {
return new UserAgentContext() {
public HttpRequest createHttpRequest() {
return new HttpRequest() {
private byte[] bytes;
private Vector<ReadyStateChangeListener> re... | false |
1,336 | 12,579 | 12,760,982 | @Override
public DataTable generateDataTable(Query query, HttpServletRequest request) throws DataSourceException {
String url = request.getParameter(URL_PARAM_NAME);
if (StringUtils.isEmpty(url)) {
log.error("url parameter not provided.");
throw new DataSourceException(Re... | public static String MD5Encode(String password) {
MessageDigest messageDigest;
try {
messageDigest = MessageDigest.getInstance("MD5");
messageDigest.update(password.getBytes());
final byte[] digest = messageDigest.digest();
final StringBuilder buf = ne... | false |
1,337 | 11,090,451 | 481,375 | public static String md5(String str) {
try {
MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
digest.update(str.getBytes());
byte messageDigest[] = digest.digest();
StringBuffer hexString = new StringBuffer();
for (int i = 0; ... | public void bubbleSort(int[] arr) {
boolean swapped = true;
int j = 0;
int tmp;
while (swapped) {
swapped = false;
j++;
for (int i = 0; i < arr.length - j; i++) {
if (arr[i] > arr[i + 1]) {
tmp = arr[i];
... | false |
1,338 | 19,344,016 | 10,349,788 | public static synchronized String encrypt(String plaintext) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md = null;
md = MessageDigest.getInstance("SHA");
md.update(plaintext.getBytes("UTF-8"));
byte raw[] = md.digest();
String hash = (new BAS... | public static boolean checkEncode(String origin, byte[] mDigest, String algorithm) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance(algorithm);
md.update(origin.getBytes());
if (MessageDigest.isEqual(mDigest, md.digest())) {
return true;
} el... | true |
1,339 | 10,839,252 | 23,113,417 | public static String getWebContent(String remoteUrl) {
StringBuffer sb = new StringBuffer();
try {
java.net.URL url = new java.net.URL(remoteUrl);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((lin... | public TreeNode fetchArchive(TreeNode owner, int id) throws Exception {
builder.start(owner, false);
parser.setDocumentHandler(builder);
String arg = server + "?todo=archive&db=" + db + "&document=" + document + "&id=" + id;
URL url = new URL(arg);
URLConnection con = url.ope... | false |
1,340 | 20,303,339 | 10,682,592 | private void trainDepParser(byte flag, JarArchiveOutputStream zout) throws Exception {
AbstractDepParser parser = null;
OneVsAllDecoder decoder = null;
if (flag == ShiftPopParser.FLAG_TRAIN_LEXICON) {
System.out.println("\n* Save lexica");
if (s_depParser.equals(Abstr... | private InputStream open(String url) throws IOException {
debug(url);
if (!useCache) {
return new URL(url).openStream();
}
File f = new File(System.getProperty("java.io.tmpdir", "."), Digest.SHA1.encrypt(url) + ".xml");
debug("Cache : " + f);
if (f.exists(... | true |
1,341 | 548,601 | 4,489,007 | public static void test(String args[]) {
int trace;
int bytes_read = 0;
int last_contentLenght = 0;
try {
BufferedReader reader;
URL url;
url = new URL(args[0]);
URLConnection istream = url.openConnection();
last_contentLeng... | Object onSuccess() {
this.mErrorExist = true;
this.mErrorMdp = true;
if (!mClientManager.exists(this.mNewMail)) {
this.mErrorExist = false;
if (mNewMdp.equals(mNewMdpConfirm)) {
this.mErrorMdp = false;
MessageDigest sha1Instance;
... | false |
1,342 | 11,312,022 | 3,298,293 | public static void downloadFromUrl(URL url, String localFilename, String userAgent) throws IOException {
InputStream is = null;
FileOutputStream fos = null;
System.setProperty("java.net.useSystemProxies", "true");
try {
URLConnection urlConn = url.openConnection();
... | public static InputStream download_file(String sessionid, String key) {
String urlString = "https://s2.cloud.cm/rpc/raw?c=Storage&m=download_file&key=" + key;
try {
URL url = new URL(urlString);
Log.d("current running function name:", "download_file");
HttpURLConn... | false |
1,343 | 8,506,682 | 21,273,051 | public static File getFileFromURL(URL url) {
File tempFile;
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
String tempDir = System.getProperty("java.io.tmpdir", ".");
tempFile = File.createTempFile("xxindex", ".tmp", new File(tempDir));
... | public RobotList<Float> sort_incr_Float(RobotList<Float> list, String field) {
int length = list.size();
Index_value[] distri = new Index_value[length];
for (int i = 0; i < length; i++) {
distri[i] = new Index_value(i, list.get(i));
}
boolean permut;
do {
... | false |
1,344 | 21,823,682 | 22,870,704 | @SuppressWarnings("unchecked")
protected void displayFreeMarkerResponse(HttpServletRequest request, HttpServletResponse response, String templateName, Map<String, Object> variableMap) throws IOException {
Enumeration<String> attrNameEnum = request.getSession().getAttributeNames();
String attrNam... | public static byte[] readHTTPFile(String url, StringBuffer contentType, StringBuffer encoding) {
try {
URL u = new URL(url);
URLConnection urlConn = u.openConnection();
urlConn.setReadTimeout(10 * 1000);
urlConn.setConnectTimeout(10 * 1000);
urlCon... | false |
1,345 | 4,721,547 | 7,232,330 | public static void main(String[] args) throws Exception {
String infile = "C:\\copy.sql";
String outfile = "C:\\copy.txt";
FileInputStream fin = new FileInputStream(infile);
FileOutputStream fout = new FileOutputStream(outfile);
FileChannel fcin = fin.getChannel();
Fi... | public LocalizationSolver(String name, String serverIP, int portNum, String workDir) {
this.info = new HashMap<String, Object>();
this.workDir = workDir;
try {
Socket solverSocket = new Socket(serverIP, portNum);
this.fromServer = new Scanner(solverSocket.getInputStre... | true |
1,346 | 6,378,837 | 7,306,113 | public static long download(String address, String localFileName) throws Exception {
OutputStream out = null;
URLConnection conn = null;
InputStream in = null;
long numWritten = 0;
try {
URL url = new URL(address);
out = new BufferedOutputStream(new Fi... | @Override
public void setOntology1Document(URL url1) throws IllegalArgumentException {
if (url1 == null) throw new IllegalArgumentException("Input parameter URL for ontology 1 is null.");
try {
ont1 = OWLManager.createOWLOntologyManager().loadOntologyFromOntologyDocument(url1.openStr... | false |
1,347 | 9,880,330 | 17,194,629 | protected static String stringOfUrl(String addr) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
URL url = new URL(addr);
URLConnection c = url.openConnection();
c.setConnectTimeout(2000);
IOUtils.copy(c.getInputStream(), output);
retu... | public static InputStream openRemoteFile(URL urlParam) throws KExceptionClass {
InputStream result = null;
try {
result = urlParam.openStream();
} catch (IOException error) {
String message = new String();
message = "No se puede abrir el recurso [";
... | false |
1,348 | 17,927,694 | 11,090,448 | public static void copyFile(FileInputStream source, FileOutputStream target) throws Exception {
FileChannel inChannel = source.getChannel();
FileChannel outChannel = target.getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
} catch (IOException e) ... | public static Object fetchCached(String address, int hours) throws MalformedURLException, IOException {
String cacheName = md5(address);
checkAndCreateDirectoryIfNeeded();
File r = new File(CACHELOCATION + cacheName);
Date d = new Date();
long limit = d.getTime() - (1000 * 60... | true |
1,349 | 14,386,499 | 21,947,196 | public synchronized String encrypt(String plaintext) throws SystemUnavailableException {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA");
} catch (NoSuchAlgorithmException e) {
throw new SystemUnavailableException(e.getMessage());
}
... | public synchronized String encrypt(final String pPassword) throws NoSuchAlgorithmException, UnsupportedEncodingException {
final MessageDigest md = MessageDigest.getInstance("SHA");
md.update(pPassword.getBytes("UTF-8"));
final byte raw[] = md.digest();
return BASE64Encoder.encodeBuf... | true |
1,350 | 12,465,375 | 1,577,152 | private void write(File src, File dst, byte id3v1Tag[], byte id3v2HeadTag[], byte id3v2TailTag[]) throws IOException {
if (src == null || !src.exists()) throw new IOException(Debug.getDebug("missing src", src));
if (!src.getName().toLowerCase().endsWith(".mp3")) throw new IOException(Debug.getDebug(... | public void run() {
try {
File inf = new File(dest);
if (!inf.exists()) {
inf.getParentFile().mkdirs();
}
FileChannel in = new FileInputStream(src).getChannel();
FileCh... | true |
1,351 | 18,099,086 | 21,253,562 | @Override
protected void service(final HttpServletRequest req, final HttpServletResponse res) throws ServletException, IOException {
res.setHeader("X-Generator", "VisualMon");
String path = req.getPathInfo();
if (null == path || "".equals(path)) res.sendRedirect(req.getServletPath() + "/... | @Override
public void fileUpload(UploadEvent uploadEvent) {
FileOutputStream tmpOutStream = null;
try {
tmpUpload = File.createTempFile("projectImport", ".xml");
tmpOutStream = new FileOutputStream(tmpUpload);
IOUtils.copy(uploadEve... | true |
1,352 | 250,595 | 2,325,202 | public static boolean encodeFileToFile(String infile, String outfile) {
boolean success = false;
java.io.InputStream in = null;
java.io.OutputStream out = null;
try {
in = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)), Base64.... | protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
ActionMessages errors = new ActionMessages();
try {
boolean isMultipart = FileUpload.isMultipartContent(request);
Store store... | true |
1,353 | 3,772,396 | 21,302,551 | public static String encryptPassword(String password) {
try {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(password.getBytes());
byte[] hash = md.digest();
StringBuffer hashStringBuf = new StringBuffer();
String byteString;
... | public static Document convertHtmlToXml(final InputStream htmlInputStream, final String classpathXsltResource, final String encoding) {
Parser p = new Parser();
javax.xml.parsers.DocumentBuilder db;
try {
db = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuil... | false |
1,354 | 662,799 | 8,539,546 | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | private static void unpackEntry(File destinationFile, ZipInputStream zin, ZipEntry entry) throws Exception {
if (!entry.isDirectory()) {
createFolders(destinationFile.getParentFile());
FileOutputStream fis = new FileOutputStream(destinationFile);
try {
IOU... | true |
1,355 | 756,962 | 6,692,645 | public void convert(File src, File dest) throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(src));
DcmParser p = pfact.newDcmParser(in);
Dataset ds = fact.newDataset();
p.setDcmHandler(ds.getDcmHandler());
try {
FileFormat format = p... | public LOCKSSDaemonStatusTableTO getDataFromDaemonStatusTableByHttps() throws HttpResponseException {
LOCKSSDaemonStatusTableXmlStreamParser ldstxp = null;
LOCKSSDaemonStatusTableTO ldstTO = null;
HttpEntity entity = null;
HttpGet httpget = null;
xstream.setMode(XStream.NO_RE... | false |
1,356 | 2,191,115 | 1,734,007 | protected List<Datastream> getDatastreams(final DepositCollection pDeposit) throws IOException, SWORDException {
List<Datastream> tDatastreams = super.getDatastreams(pDeposit);
FileInputStream tInput = null;
String tFileName = ((LocalDatastream) tDatastreams.get(0)).getPath();
String... | private InputStream getConnection() throws BaseException {
OutputStreamWriter wr = null;
try {
StringBuilder sb = new StringBuilder();
sb.append(getBaseString());
sb.append(AND);
sb.append(encode(ACTION, ENCODING));
sb.append(EQUAL);
... | false |
1,357 | 7,726,775 | 7,276,772 | public void write(URL exportUrl, OutputStream output) throws Exception {
if (exportUrl == null || output == null) {
throw new DocumentListException("null passed in for required parameters");
}
MediaContent mc = new MediaContent();
mc.setUri(exportUrl.toString());
... | public void testBlobB() {
ResultSet rs;
byte[] ba;
byte[] baR1 = new byte[] { (byte) 0xF1, (byte) 0xF2, (byte) 0xF3, (byte) 0xF4, (byte) 0xF5, (byte) 0xF6, (byte) 0xF7, (byte) 0xF8, (byte) 0xF9, (byte) 0xFA, (byte) 0xFB };
byte[] baR2 = new byte[] { (byte) 0xE1, (byte) 0xE2, (byte) 0... | false |
1,358 | 18,269,393 | 2,775,424 | public static File getClassLoaderFile(String filename) throws IOException {
Resource resource = new ClassPathResource(filename);
try {
return resource.getFile();
} catch (IOException e) {
}
InputStream is = null;
FileOutputStream os = null;
try {
... | protected void truncate(File file) {
LogLog.debug("Compression of file: " + file.getAbsolutePath() + " started.");
if (FileUtils.isFileOlder(file, ManagementFactory.getRuntimeMXBean().getStartTime())) {
File backupRoot = new File(getBackupDir());
if (!backupRoot.exists() && !... | true |
1,359 | 23,677,138 | 5,186,187 | public static void BubbleSortDouble2(double[] num) {
int last_exchange;
int right_border = num.length - 1;
do {
last_exchange = 0;
for (int j = 0; j < num.length - 1; j++) {
if (num[j] > num[j + 1])
{
double temp = num[j];
num[j] = num[j + 1];
num[j + 1] = temp;
last_exchange = ... | public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
URL url;
URLConnection urlConn;
DataOutputStream cgiInput;
url = new URL("http://localhost:8080/ListeOnLine/Target");
... | false |
1,360 | 16,344,667 | 8,983,114 | public static String getUrl(String urlString) {
int retries = 0;
String result = "";
while (true) {
try {
URL url = new URL(urlString);
BufferedReader rdr = new BufferedReader(new InputStreamReader(url.openStream()));
String line = ... | @Test
public void testWrite() {
System.out.println("write");
final File[] files = { new File(sharePath) };
System.out.println("Creating hash...");
String initHash = MD5File.MD5Directory(files[0]);
System.out.println("Hash: " + initHash);
Share readShare = ShareUti... | false |
1,361 | 4,871,307 | 12,787,570 | private boolean authenticateWithServer(String user, String password) {
Object o;
String response;
byte[] dataKey;
try {
o = objectIn.readObject();
if (o instanceof String) {
response = (String) o;
Debug.netMsg("Connected to JFri... | private static void copyContent(final File srcFile, final File dstFile, final boolean gzipContent) throws IOException {
final File dstFolder = dstFile.getParentFile();
dstFolder.mkdirs();
if (!dstFolder.exists()) {
throw new RuntimeException("Unable to create the folder " + dstFo... | false |
1,362 | 18,662,539 | 6,635,999 | @Override
public void start() {
try {
ftp = new FTPClient();
ftp.connect(this.url.getHost(), this.url.getPort() == -1 ? this.url.getDefaultPort() : this.url.getPort());
String username = "anonymous";
String password = "";
if (this.url.getUserIn... | public String grabId(String itemName) throws Exception {
StringBuffer modified = new StringBuffer(itemName);
for (int i = 0; i <= modified.length() - 1; i++) {
char ichar = modified.charAt(i);
if (ichar == ' ') modified = modified.replace(i, i + 1, "+");
}
ite... | false |
1,363 | 6,989,198 | 592,597 | public static boolean isInternetReachable() {
try {
URL url = new URL("http://code.google.com/p/ilias-userimport/downloads/list");
HttpURLConnection urlConnect = (HttpURLConnection) url.openConnection();
Object objData = urlConnect.getContent();
} catch (UnknownHo... | @Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == btnRegister) {
Error.log(6002, "Bot�o cadastrar pressionado por " + login + ".");
if (nameUser.getText().compareTo("") == 0) {
JOptionPane.showMessageDialog(null, "... | false |
1,364 | 4,937,926 | 10,426,070 | @Override
public RServiceResponse execute(final NexusServiceRequest inData) throws NexusServiceException {
final RServiceRequest data = (RServiceRequest) inData;
final RServiceResponse retval = new RServiceResponse();
final StringBuilder result = new StringBuilder("R service call results... | public static long copy(File src, long amount, File dst) {
final int BUFFER_SIZE = 1024;
long amountToRead = amount;
InputStream in = null;
OutputStream out = null;
try {
in = new BufferedInputStream(new FileInputStream(src));
out = new BufferedOutputS... | true |
1,365 | 3,772,396 | 375,390 | public static String encryptPassword(String password) {
try {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(password.getBytes());
byte[] hash = md.digest();
StringBuffer hashStringBuf = new StringBuffer();
String byteString;
... | public void connected(String address, int port) {
connected = true;
try {
if (localConnection) {
byte key[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
si.setEncryptionKey(key);
} else {
saveData(address, p... | true |
1,366 | 4,162,691 | 14,024,978 | private static String getData(String myurl) throws Exception {
URL url = new URL(myurl);
uc = (HttpURLConnection) url.openConnection();
if (login) {
uc.setRequestProperty("Cookie", usercookie + ";" + pwdcookie);
}
br = new BufferedReader(new InputStreamReader(uc.g... | public static final String generate(String value) {
try {
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
md.update(value.getBytes());
byte[] hash = md.digest();
StringBuffer hexString = new StringBuffer();
for (int... | false |
1,367 | 3,857,069 | 20,250,217 | public void run(IAction action) {
int style = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getStyle();
Shell shell = new Shell((style & SWT.MIRRORED) != 0 ? SWT.RIGHT_TO_LEFT : SWT.NONE);
GraphicalViewer viewer = new ScrollingGraphicalViewer();
viewer.createControl... | private byte[] getBytesFromUrl(URL url) {
ByteArrayOutputStream bais = new ByteArrayOutputStream();
InputStream is = null;
try {
is = url.openStream();
byte[] byteChunk = new byte[4096];
int n;
while ((n = is.read(byteChunk)) > 0) {
... | false |
1,368 | 709,510 | 19,799,875 | static void sort(int[] a) {
int i = 0;
while (i < a.length - 1) {
int j = 0;
while (j < (a.length - i) - 1) {
if (a[j] > a[j + 1]) {
int aux = a[j];
a[j] = a[j + 1];
a[j + 1] = aux;
}
... | public void run() {
try {
URL url = new URL("http://www.sourceforge.net/projects/beobachter/files/beobachter_version.html");
InputStreamReader reader = new InputStreamReader(url.openStream());
BufferedReader buffer = new BufferedReader(reader);
String version ... | false |
1,369 | 18,048,836 | 1,699,613 | public void modify(ModifyInterceptorChain chain, DistinguishedName dn, ArrayList<LDAPModification> mods, LDAPConstraints constraints) throws LDAPException {
Connection con = (Connection) chain.getRequest().get(JdbcInsert.MYVD_DB_CON + this.dbInsertName);
if (con == null) {
throw new LDAP... | private static void doCopyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException {
if (destFile.exists() && destFile.isDirectory()) {
throw new IOException("Destination '" + destFile + "' exists but is a directory");
}
FileInputStream input = new FileInput... | false |
1,370 | 16,981,230 | 6,081,622 | public static String encrypt(final String password, final String algorithm, final byte[] salt) {
final StringBuffer buffer = new StringBuffer();
MessageDigest digest = null;
int size = 0;
if ("CRYPT".equalsIgnoreCase(algorithm)) {
throw new InternalError("Not implemented"... | public String encryptStringWithKey(String to_be_encrypted, String aKey) {
String encrypted_value = "";
char xdigit[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
MessageDigest messageDigest;
try {
messageDigest = MessageDigest.getI... | true |
1,371 | 8,979,065 | 9,806,128 | public void copyFile(File source, File destination) {
try {
FileInputStream sourceStream = new FileInputStream(source);
try {
FileOutputStream destinationStream = new FileOutputStream(destination);
try {
FileChannel sourceChannel = ... | private void _readValuesFromNetwork() {
if (_intrinsicValuesByAttribute == null) {
NSMutableDictionary<String, Object> values = new NSMutableDictionary<String, Object>(3);
values.setObjectForKey(Boolean.FALSE, "NetworkFailure");
try {
URLConnection connect... | false |
1,372 | 282,874 | 10,006,681 | public void elimina(Cliente cli) throws errorSQL, errorConexionBD {
System.out.println("GestorCliente.elimina()");
int id = cli.getId();
String sql;
Statement stmt = null;
try {
gd.begin();
sql = "DELETE FROM cliente WHERE cod_cliente =" + id;
... | 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());
}
... | false |
1,373 | 20,741,536 | 19,627,256 | public static void copyFile(File src, File dst) throws IOException {
FileChannel inChannel = new FileInputStream(src).getChannel();
FileChannel outChannel = new FileOutputStream(dst).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
} finally {
... | public void compile(Project project) throws ProjectCompilerException {
List<Resource> resources = project.getModel().getResource();
for (Resource resource : resources) {
try {
IOUtils.copy(srcDir.getRelative(resource.getLocation()).getInputStream(), outDir.getRelative(res... | true |
1,374 | 16,529,002 | 246,646 | public static boolean copy(File source, File dest) {
FileChannel in = null, out = null;
try {
in = new FileInputStream(source).getChannel();
out = new FileOutputStream(dest).getChannel();
long size = in.size();
MappedByteBuffer buf = in.map(FileChannel... | public void elimina(Cliente cli) throws errorSQL, errorConexionBD {
System.out.println("GestorCliente.elimina()");
int id = cli.getId();
String sql;
Statement stmt = null;
try {
gd.begin();
sql = "DELETE FROM cliente WHERE cod_cliente =" + id;
... | false |
1,375 | 22,545,244 | 49,834 | public static String encryptStringWithSHA2(String input) {
String output = null;
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA-256");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
md.update(input.getBytes())... | public String encryptPassword(String clearPassword) throws NullPointerException {
MessageDigest sha;
try {
sha = MessageDigest.getInstance("SHA");
} catch (NoSuchAlgorithmException e) {
throw new NullPointerException("NoSuchAlgorithmException: " + e.toString());
... | true |
1,376 | 10,118,785 | 16,762,677 | @Override
public void download(String remoteFilePath, String localFilePath) {
InputStream remoteStream = null;
try {
remoteStream = client.get(remoteFilePath);
} catch (IOException e) {
e.printStackTrace();
}
OutputStream localStream = null;
... | public static void copyFile(File src, File dest) throws IOException {
FileInputStream fIn;
FileOutputStream fOut;
FileChannel fIChan, fOChan;
long fSize;
MappedByteBuffer mBuf;
fIn = new FileInputStream(src);
fOut = new FileOutputStream(dest);
fIChan =... | true |
1,377 | 15,195,064 | 11,939,522 | public int[] do_it(final int[] x) {
int temp = 0;
int j = x.length;
while (j > 0) {
for (int i = 0; i < j - 1; i++) {
if (x[i] > x[i + 1]) {
temp = x[i];
x[i] = x[i + 1];
x[i + 1] = temp;
... | public static String[] bubbleSort(String[] unsortedString, boolean ascending) {
if (unsortedString.length < 2) return unsortedString;
String[] sortedString = new String[unsortedString.length];
for (int i = 0; i < unsortedString.length; i++) {
sortedString[i] = unsortedString[i];
... | true |
1,378 | 13,387,011 | 9,918,348 | private void updateViewerContent(ScrollingGraphicalViewer viewer) {
BioPAXGraph graph = (BioPAXGraph) viewer.getContents().getModel();
if (!graph.isMechanistic()) return;
Map<String, Color> highlightMap = new HashMap<String, Color>();
for (Object o : graph.getNodes()) {
I... | public static ArrayList[] imageSearch(String imageQuery, int startingIndex) {
try {
imageQuery = URLEncoder.encode(imageQuery, "UTF-8");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
String queryS = new String(... | false |
1,379 | 16,005,064 | 783,717 | private void setInlineXML(Entry entry, DatastreamXMLMetadata ds) throws UnsupportedEncodingException, StreamIOException {
String content;
if (m_obj.hasContentModel(Models.SERVICE_DEPLOYMENT_3_0) && (ds.DatastreamID.equals("SERVICE-PROFILE") || ds.DatastreamID.equals("WSDL"))) {
content =... | public static void main(String[] args) throws Exception {
String uri = args[0];
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(uri), conf);
FSDataInputStream in = null;
try {
in = fs.open(new Path(uri));
IOUtils.cop... | true |
1,380 | 16,845,107 | 2,105,651 | public boolean copyFile(File destinationFolder, File fromFile) {
boolean result = false;
String toFileName = destinationFolder.getAbsolutePath() + "/" + fromFile.getName();
File toFile = new File(toFileName);
FileInputStream from = null;
FileOutputStream to = null;
tr... | public void process(String src, String dest) {
try {
KanjiDAO kanjiDAO = KanjiDAOFactory.getDAO();
MorphologicalAnalyzer mecab = MorphologicalAnalyzer.getInstance();
if (mecab.isActive()) {
BufferedReader br = new BufferedReader(new InputStreamReader(new F... | true |
1,381 | 13,776,078 | 17,402,775 | private GmailContact convertContactToGmailContact(Contact contact) throws GmailManagerException {
boolean homePhone = false, homePhone2 = false, homeFax = false, homeMobile = false, homePager = false;
boolean businessPhone = false, businessPhone2 = false, businessFax = false, businessMobile = false,... | public String getResourceAsString(String name) throws IOException {
String content = null;
InputStream stream = aClass.getResourceAsStream(name);
if (stream != null) {
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
IOUtils.copyAndClose(stream, buffer);
... | false |
1,382 | 8,558,409 | 23,634,465 | public static final void zip(final ZipOutputStream out, final File f, String base) throws Exception {
if (f.isDirectory()) {
final File[] fl = f.listFiles();
base = base.length() == 0 ? "" : base + File.separator;
for (final File element : fl) {
zip(out, e... | private static void zip(File d) throws FileNotFoundException, IOException {
String[] entries = d.list();
byte[] buffer = new byte[4096];
int bytesRead;
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(new File(d.getParent() + File.separator + "dist.zip")));
for ... | true |
1,383 | 14,166,352 | 4,452,454 | public static boolean downloadFile(String urlString, String outputFile, int protocol) {
InputStream is = null;
File file = new File(outputFile);
FileOutputStream fos = null;
if (protocol == HTTP_PROTOCOL) {
try {
URL url = new URL(urlString);
... | private InputStream getManifestAsResource() {
ClassLoader cl = getClass().getClassLoader();
try {
Enumeration manifests = cl != null ? cl.getResources(Constants.OSGI_BUNDLE_MANIFEST) : ClassLoader.getSystemResources(Constants.OSGI_BUNDLE_MANIFEST);
while (manifests.hasMoreEle... | false |
1,384 | 638,175 | 20,547,900 | void run(String[] args) {
InputStream istream = System.in;
System.out.println("TradeMaximizer " + version);
String filename = parseArgs(args, false);
if (filename != null) {
System.out.println("Input from: " + filename);
try {
if (filename.star... | public static String md5(String source) {
MessageDigest md;
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
try {
md = MessageDigest.getInstance("MD5");
md.update(source.getBytes());
byte[] digested = md.digest();
... | true |
1,385 | 14,689,323 | 16,540,473 | public void serveResource(HTTPResource resource, HttpServletRequest request, HttpServletResponse response) throws java.io.IOException {
Image image = (Image) resource;
log.debug("Serving: " + image);
URL url = image.getResourceURL();
int idx = url.toString().lastIndexOf(".");
... | public static void copyFile(File sourceFile, File destFile) throws IOException {
if (!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
try {
source = new FileInputStream(sourceFile).getChannel(... | false |
1,386 | 19,925,085 | 6,013,590 | public static void main(String[] args) {
JFileChooser askDir = new JFileChooser();
askDir.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
askDir.setMultiSelectionEnabled(false);
int returnVal = askDir.showOpenDialog(null);
if (returnVal == JFileChooser.CANCEL_OPTION) {
... | public void saveUserUpFile(UserInfo userInfo, String distFileName, InputStream instream) throws IOException {
String fullPicFile = BBSCSUtil.getUserWebFilePath(userInfo.getId()) + distFileName;
String fullPicFileSmall = BBSCSUtil.getUserWebFilePath(userInfo.getId()) + distFileName + Constant.IMG_SMA... | true |
1,387 | 765,103 | 12,499,532 | public void convert(File src, File dest) throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(src));
DcmParser p = pfact.newDcmParser(in);
Dataset ds = fact.newDataset();
p.setDcmHandler(ds.getDcmHandler());
try {
FileFormat format = p... | public File copyLocalFileAsTempFileInExternallyAccessableDir(String localFileRef) throws IOException {
log.debug("copyLocalFileAsTempFileInExternallyAccessableDir");
File f = this.createTempFileInExternallyAccessableDir();
FileChannel srcChannel = new FileInputStream(localFileRef).getChannel... | true |
1,388 | 19,898,737 | 23,010,293 | private void updateSystem() throws IOException {
String stringUrl="http://code.google.com/p/senai-pe-cronos/downloads/list";
try {
url = new URL(stringUrl);
} catch (MalformedURLException ex) {
ex.printStackTrace();
}
InputStream is = url.openStream(... | public static String getTextFromUrl(final String url) throws IOException {
final String lineSeparator = System.getProperty("line.separator");
InputStreamReader inputStreamReader = null;
BufferedReader bufferedReader = null;
try {
final StringBuilder result = new StringBui... | true |
1,389 | 23,047,157 | 10,878,119 | @Override
public void run() {
long timeout = 10 * 1000L;
long start = (new Date()).getTime();
try {
InputStream is = socket.getInputStream();
boolean available = false;
while (!available && !socket.isClosed()) {
... | public void notifyIterationEnds(final IterationEndsEvent event) {
log.info("moving files...");
File source = new File("deqsim.log");
if (source.exists()) {
File destination = new File(Controler.getIterationFilename("deqsim.log"));
if (!IOUtils.renameFile(source, desti... | true |
1,390 | 615,358 | 6,031,248 | public static void decompressFile(File orig) throws IOException {
File file = new File(INPUT + orig.toString());
File target = new File(OUTPUT + orig.toString().replaceAll(".xml.gz", ".xml"));
System.out.println(" Decompressing \"" + file.getName() + "\" into \"" + target + "\"");
... | public static void copyFile(File source, File dest) throws IOException {
FileChannel in = null, out = null;
try {
in = new FileInputStream(source).getChannel();
out = new FileOutputStream(dest).getChannel();
long size = in.size();
MappedByteBuffer buf ... | true |
1,391 | 13,883,878 | 17,630,907 | PathElement(String path) throws MaxError {
this.path = path;
if (path.startsWith("http:")) {
try {
url = new URL(path);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("HEAD... | public static int[] sortDescending(int input[]) {
int[] order = new int[input.length];
for (int i = 0; i < order.length; i++) order[i] = i;
for (int i = input.length; --i >= 0; ) {
for (int j = 0; j < i; j++) {
if (input[j] < input[j + 1]) {
in... | false |
1,392 | 6,171,420 | 21,022,202 | public static void copyFile(File sourceFile, File destFile) throws IOException {
log.info("Copying file '" + sourceFile + "' to '" + destFile + "'");
if (!sourceFile.isFile()) {
throw new IllegalArgumentException("The sourceFile '" + sourceFile + "' does not exist or is not a normal file... | public void end() throws Exception {
handle.waitFor();
Calendar endTime = Calendar.getInstance();
File resultsDir = new File(runDir, "results");
if (!resultsDir.isDirectory()) throw new Exception("The results directory not found!");
String resHtml = null;
String resTx... | true |
1,393 | 8,344,457 | 777,609 | private static void addFileToZip(String path, String srcFile, ZipOutputStream zip, String prefix, String suffix) throws Exception {
File folder = new File(srcFile);
if (folder.isDirectory()) {
addFolderToZip(path, srcFile, zip, prefix, suffix);
} else {
if (isFileName... | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | true |
1,394 | 7,905,116 | 4,830,850 | protected List<? extends SearchResult> searchVideo(String words, int number, int offset, CancelMonitor cancelMonitor) {
List<VideoSearchResult> resultsList = new ArrayList<>();
try {
// set up the HTTP request factory
HttpTransport transport = new NetHttpTransport();
HttpRequestFactory factory = transport... | @Override
public synchronized void deleteHardDiskStatistics(String contextName, String path, Date dateFrom, Date dateTo) throws DatabaseException {
final Connection connection = this.getConnection();
try {
connection.setAutoCommit(false);
String queryString = "DELETE " + ... | false |
1,395 | 7,118,204 | 10,265,164 | private static String doGetForSessionKey(String authCode) throws Exception {
String sessionKey = "";
HttpClient hc = new DefaultHttpClient();
HttpGet hg = new HttpGet(Common.TEST_SESSION_HOST + Common.TEST_SESSION_PARAM + authCode);
HttpResponse hr = hc.execute(hg);
BufferedR... | public String getLatestVersion(String website) {
String latestVersion = "";
try {
URL url = new URL(website + "/version");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(url.openStream()));
String string;
while ((string = buff... | true |
1,396 | 23,053,699 | 3,024,983 | public void copy(File from, String to) throws SystemException {
assert from != null;
File dst = new File(folder, to);
dst.getParentFile().mkdirs();
FileChannel in = null;
FileChannel out = null;
try {
if (!dst.exists()) dst.createNewFile();
in ... | @Test
public void testCopy_inputStreamToWriter_Encoding_nullEncoding() throws Exception {
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStreamTest(in);
ByteArrayOutputStream baout = new ByteArrayOutputStream();
YellOnFlushAndCloseOutputStreamTest out... | true |
1,397 | 10,432,260 | 975,289 | private void appendArchive() throws Exception {
String cmd;
if (profile == CompilationProfile.UNIX_GCC) {
cmd = "cat";
} else if (profile == CompilationProfile.MINGW_WINDOWS) {
cmd = "type";
} else {
throw new Exception("Unknown cat equivalent for ... | public static void copy(File from, File to, CopyMode mode) throws IOException {
if (!from.exists()) {
IllegalArgumentException e = new IllegalArgumentException("Source doesn't exist: " + from.getCanonicalFile());
log.throwing("Utils", "copy", e);
throw e;
}
... | true |
1,398 | 11,075,647 | 7,757,210 | @Test
public void testWriteModel() {
Model model = new Model();
model.setName("MY_MODEL1");
Stereotype st1 = new Stereotype();
st1.setName("Pirulito1");
PackageObject p1 = new PackageObject("p1");
ClassType type1 = new ClassType("Class1");
type1.setStereot... | @RequestMapping("/download")
public void download(HttpServletRequest request, HttpServletResponse response) {
InputStream input = null;
ServletOutputStream output = null;
try {
String savePath = request.getSession().getServletContext().getRealPath("/upload");
Stri... | true |
1,399 | 10,480,051 | 3,739,492 | public static RecordResponse loadRecord(RecordRequest recordRequest) {
RecordResponse recordResponse = new RecordResponse();
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(recordRequest.isContact() ? URL_RECORD_CONTACT : URL_REC... | public static boolean downloadFile(String url, String destination) {
BufferedInputStream bi = null;
BufferedOutputStream bo = null;
File destfile;
try {
java.net.URL fileurl;
try {
fileurl = new java.net.URL(url);
} catch (Malformed... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.