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 |
|---|---|---|---|---|---|
4,400 | 11,481,709 | 19,452,177 | public boolean copy(File fromFile) throws IOException {
FileUtility toFile = this;
if (!fromFile.exists()) {
abort("FileUtility: no such source file: " + fromFile.getAbsolutePath());
return false;
}
if (!fromFile.isFile()) {
abort("FileUtility: can... | public static File createTempFile(InputStream contentStream, String ext) throws IOException {
ExceptionUtils.throwIfNull(contentStream, "contentStream");
File file = File.createTempFile("test", ext);
FileOutputStream fos = new FileOutputStream(file);
try {
IOUtils.copy(co... | true |
4,401 | 9,456,659 | 18,374,477 | public static String getHash(String text) {
if (text == null) return null;
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(text.getBytes());
byte[] hashedTextBytes = md.digest();
BigInteger hashedTextBigInteger = new BigInteger(1, ... | public void insertUser(final User user) throws IOException {
try {
Connection conn = null;
boolean autoCommit = false;
try {
conn = pool.getConnection();
autoCommit = conn.getAutoCommit();
conn.setAutoCommit(false);
... | false |
4,402 | 18,269,744 | 23,124,633 | 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.... | private void saveFile(Folder folder, Object key, InputStream stream) throws FileManagerException {
File file = new File(folder, key.toString());
LOGGER.debug("Writing file: " + file.getAbsolutePath());
Writer writer = null;
Writer encodedWriter = null;
try {
encod... | true |
4,403 | 282,431 | 20,407,275 | 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... | @NotNull
private Properties loadProperties() {
File file = new File(homeLocator.getHomeDir(), configFilename);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
throw new RuntimeException("IOException while creatin... | true |
4,404 | 11,566,433 | 8,827,646 | public void write(File file) throws Exception {
if (getGEDCOMFile() != null) {
size = getGEDCOMFile().length();
if (!getGEDCOMFile().renameTo(file)) {
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
... | @SuppressWarnings("unchecked")
private List getURLList(String request) throws IOException {
List list = null;
try {
URL url = new URL(dbURL + request);
URLConnection conn = url.openConnection();
conn.connect();
JSONParser parser = JSONParser.defaul... | false |
4,405 | 1,347,808 | 8,437,742 | public static void main(String[] args) throws IOException {
FileOutputStream f = new FileOutputStream("test.zip");
CheckedOutputStream csum = new CheckedOutputStream(f, new Adler32());
ZipOutputStream zos = new ZipOutputStream(csum);
BufferedOutputStream out = new BufferedOutputStrea... | protected void copy(URL url, File file) throws IOException {
InputStream in = null;
FileOutputStream out = null;
try {
in = url.openStream();
out = new FileOutputStream(file);
IOUtils.copy(in, out);
} finally {
if (out != null) {
... | true |
4,406 | 19,710,228 | 19,556,732 | public void init(String password) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(password.getBytes("UTF-8"), 0, password.length());
byte[] rawKey = md.digest();
skeySpec = new SecretKeySpec(rawKey, "AES");
ivSpec = new IvPar... | public boolean verifySignature() {
try {
byte[] data = readFile(name + ".tmp1.bin");
if (data == null) return false;
if (data[data.length - 0x104] != 'N' || data[data.length - 0x103] != 'G' || data[data.length - 0x102] != 'I' || data[data.length - 0x101] != 'S') return fa... | true |
4,407 | 241,286 | 1,113,238 | 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 ResourceMigrator createDefaultResourceMigrator(NotificationReporter reporter, boolean strictMode) throws ResourceMigrationException {
return new ResourceMigrator() {
public void migrate(InputMetadata meta, InputStream inputStream, OutputCreator outputCreator) throws IOExcepti... | true |
4,408 | 2,021,567 | 10,480,049 | public boolean storeFile(String local, String remote) throws IOException {
boolean stored = false;
GridFTP ftp = new GridFTP();
ftp.setDefaultPort(port);
System.out.println(this + ".storeFile " + remote);
try {
ftp.connect(host);
ftp.login(username, pa... | public static SearchItem register(String... args) {
SearchItem _return = new SearchItem();
String line = null;
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(URL_REGISTER);
List<NameValuePair> nameValuePairs ... | false |
4,409 | 6,492,265 | 18,366,943 | private File downloadPDB(String pdbId) {
File tempFile = new File(path + "/" + pdbId + ".pdb.gz");
File pdbHome = new File(path);
if (!pdbHome.canWrite()) {
System.err.println("can not write to " + pdbHome);
return null;
}
String ftp = String.format("f... | protected InputSource getInputSource(URL url, AtomicReference<Date> checkModifiedDate) throws IOException {
String proto = url.getProtocol().toLowerCase(Locale.ENGLISH);
if (!("http".equals(proto) || "https".equals(proto))) throw new IllegalArgumentException("OAI only allows HTTP(S) as network proto... | true |
4,410 | 18,115,173 | 9,830,269 | private void copy(File in, File out) {
log.info("Copying yam file from: " + in.getName() + " to: " + out.getName());
try {
FileChannel ic = new FileInputStream(in).getChannel();
FileChannel oc = new FileOutputStream(out).getChannel();
ic.transferTo(0, ic.size(), o... | public final void deliver(final String from, final String recipient, final InputStream data) throws TooMuchDataException, IOException {
System.out.println("FROM: " + from);
System.out.println("TO: " + recipient);
final File tmpD... | true |
4,411 | 630,656 | 576,161 | public static void main(String args[]) {
int i, j, l;
short NUMNUMBERS = 256;
short numbers[] = new short[NUMNUMBERS];
Darjeeling.print("START");
for (l = 0; l < 100; l++) {
for (i = 0; i < NUMNUMBERS; i++) numbers[i] = (short) (NUMNUMBERS - 1 - i);
fo... | public boolean download(URL url, File file) {
OutputStream out = null;
URLConnection conn = null;
InputStream in = null;
try {
out = new BufferedOutputStream(new FileOutputStream(file));
conn = url.openConnection();
in = conn.getInputStream();
... | false |
4,412 | 5,335,270 | 12,082,150 | @Override
public String getData(String blipApiPath, String authHeader) {
try {
URL url = new URL(BLIP_API_URL + blipApiPath);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
if (authHeader != null) {
conn.addRequestProperty("Authoriz... | public static Set<Address> getDatosCatastrales(String pURL) {
Set<Address> result = new HashSet<Address>();
String iniCuerr = "<cuerr>";
String finCuerr = "</cuerr>";
String iniDesErr = "<des>";
String finDesErr = "</des>";
String iniInm1 = "<rcdnp>";
String f... | true |
4,413 | 6,044,146 | 21,807,527 | @Test
public void unacceptableMimeTypeTest() throws IOException {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://localhost:8080/alfresco/sword/deposit/company_home");
File file = new File("/Library/Application Support/Apple/iChat Icons/Planets/M... | public static String digest(String ha1, String ha2, String nonce) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(getBytes(ha1, ISO_8859_1));
md.update((byte) ':');
md.update(getBytes(nonce, ISO_8859_1));
md.update((byte) ':'... | false |
4,414 | 16,380,120 | 18,666,210 | @Override
public String compute_hash(String plaintext) {
MessageDigest d;
try {
d = MessageDigest.getInstance(get_algorithm_name());
d.update(plaintext.getBytes());
byte[] hash = d.digest();
StringBuffer sb = new StringBuffer();
for (by... | public void executeRequest(OperationContext context) throws Throwable {
long t1 = System.currentTimeMillis();
GetPortrayMapCapabilitiesParams params = context.getRequestOptions().getGetPortrayMapCapabilitiesOptions();
String srvCfg = context.getRequestContext().getApplicationConfiguration().... | false |
4,415 | 11,193,872 | 21,715,891 | private static <T> Collection<T> loadFromServices(Class<T> interf) throws Exception {
ClassLoader classLoader = DSServiceLoader.class.getClassLoader();
Enumeration<URL> e = classLoader.getResources("META-INF/services/" + interf.getName());
Collection<T> services = new ArrayList<T>();
... | protected void copy(File src, File dest) throws IOException {
if (src.isDirectory() && dest.isFile()) throw new IOException("Cannot copy a directory to a file");
if (src.isDirectory()) {
File newDir = new File(dest, src.getName());
if (!newDir.mkdirs()) throw new IOException(... | false |
4,416 | 15,129,122 | 15,946,011 | public void doGet(OutputStream os) throws IOException {
try {
uc = (HttpURLConnection) url.openConnection();
uc.setRequestProperty("User-Agent", USER_AGENT);
uc.setReadTimeout(READ_TIMEOUT);
logger.debug("Connect timeout=" + uc.getConnectTimeout() + " read tim... | public long calculateResponseTime(Proxy proxy) {
try {
LOGGER.debug("Test network response time for " + RESPONSE_TEST_URL);
URL urlForTest = new URL(REACH_TEST_URL);
URLConnection testConnection = urlForTest.openConnection(proxy);
long startTime = System.curre... | false |
4,417 | 22,915,885 | 21,027,584 | public Login authenticateClient() {
Object o;
String user, password;
Vector<Login> clientLogins = ClientLoginsTableModel.getClientLogins();
Login login = null;
try {
socket.setSoTimeout(25000);
objectOut.writeObject("JFRITZ SERVER 1.1");
ob... | public void run() {
try {
HttpURLConnection con = (HttpURLConnection) url.openConnection();
Osm2Model osm = new Osm2Model(pedestrian, filterCyclic);
osm.progress.connect(this, "progress(int)");
osm.parseFile(con.getInputStream(), con.getContentLength());
... | false |
4,418 | 9,348,293 | 8,990,222 | public Image storeImage(String title, String pathToImage, Map<String, Object> additionalProperties) {
File collectionFolder = ProjectManager.getInstance().getFolder(PropertyHandler.getInstance().getProperty("_default_collection_name"));
File imageFile = new File(pathToImage);
String filename... | private boolean get(String surl, File dst, Get get) throws IOException {
boolean ret = false;
InputStream is = null;
OutputStream os = null;
try {
try {
if (surl.startsWith("file://")) {
is = new FileInputStream(surl.substring(7));
... | true |
4,419 | 21,075,055 | 2,279,291 | public String digest(String algorithm, String text) {
MessageDigest digester = null;
try {
digester = MessageDigest.getInstance(algorithm);
digester.update(text.getBytes(Digester.ENCODING));
} catch (NoSuchAlgorithmException nsae) {
_log.error(nsae, nsae);... | public static String encrypt(String plainText) throws Exception {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
throw new Exception(e.getMessage());
}
try {
md.update(plainText.... | true |
4,420 | 1,528,296 | 10,005,624 | public static Hashtable DefaultLoginValues(String firstName, String lastName, String password, String mac, String startLocation, int major, int minor, int patch, int build, String platform, String viewerDigest, String userAgent, String author) throws Exception {
Hashtable values = new Hashtable();
M... | public Object run() {
try {
MessageDigest digest = MessageDigest.getInstance("SHA");
digest.update(buf.toString().getBytes());
byte[] data = digest.digest();
serialNum = new BASE64Encoder().encode(data);
... | true |
4,421 | 151,792 | 16,912,326 | public void bubblesort(String filenames[]) {
for (int i = filenames.length - 1; i > 0; i--) {
for (int j = 0; j < i; j++) {
String temp;
if (filenames[j].compareTo(filenames[j + 1]) > 0) {
temp = filenames[j];
filenames[j] =... | @Override
public void execute() throws BuildException {
if (this.toFile == null && this.toDir == null) throw new BuildException("Missing Destination File/Dir");
if (this.toFile != null && this.toDir != null) throw new BuildException("Both Defined Destination File/Dir");
if (this.urlStr =... | false |
4,422 | 3,850,809 | 3,585,152 | private void buildBundle() {
if (targetProject == null) {
MessageDialog.openError(getShell(), "Error", "No target SPAB project selected!");
return;
}
if (projectProcessDirSelector.getText().trim().length() == 0) {
MessageDialog.openError(getShell(), "Error... | public static void copy(FileInputStream from, FileOutputStream to) throws IOException {
FileChannel fromChannel = from.getChannel();
FileChannel toChannel = to.getChannel();
copy(fromChannel, toChannel);
fromChannel.close();
toChannel.close();
}
| true |
4,423 | 3,253,205 | 7,998,445 | private String generateUniqueIdMD5(Run run, HttpServletRequest request, String groupIdString) {
String portalUrl = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort();
String uniqueportalUrl = portalUrl + "run:" + run.getId().toString() + "group:" + groupIdString;
... | public static BufferedImage readDicom(final URL url, final SourceImage src) {
assert url != null;
assert src != null;
BufferedImage bi = null;
try {
DicomInputStream dis = new DicomInputStream(new BufferedInputStream(url.openStream()));
src.read(dis);
... | false |
4,424 | 19,392,404 | 11,090,448 | public boolean setSchedule(Schedule s) {
PreparedStatement pst1 = null;
PreparedStatement pst2 = null;
PreparedStatement pst3 = null;
ResultSet rs2 = null;
boolean retVal = true;
try {
conn = getConnection();
pst1 = conn.prepareStatement("INSER... | 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... | false |
4,425 | 16,165,021 | 17,241,450 | private synchronized void resetUserDictionary() {
if (this.fChecker == null) return;
if (this.fUserDictionary != null) {
this.fChecker.removeDictionary(this.fUserDictionary);
this.fUserDictionary.unload();
this.fUserDictionary = null;
}
IPreference... | public static boolean copyFile(File src, File des) {
try {
BufferedInputStream in = new BufferedInputStream(new FileInputStream(src));
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(des));
int b;
while ((b = in.read()) != -1) out.writ... | false |
4,426 | 19,276,021 | 5,859,989 | public DataSet newparse() throws SnifflibDatatypeException {
NumberFormat numformat = NumberFormat.getInstance();
if (this.headers.size() != this.types.size()) {
throw new SnifflibDatatypeException("Different number of headers (" + this.headers.size() + ") and types(" + this.types.size()... | public Integer execute(Connection con) throws SQLException {
int updateCount = 0;
boolean oldAutoCommitSetting = con.getAutoCommit();
Statement stmt = null;
try {
con.setAutoCommit(autoCommit);
stmt = con... | false |
4,427 | 21,642,957 | 1,446,728 | public void connectUrl(String url) throws MalformedURLException, IOException {
URLConnection connection = new URL(url).openConnection();
connection.connect();
connection.getInputStream().close();
connection.getOutputStream().close();
}
| private void backupFile(ZipOutputStream out, String base, String fn) throws IOException {
String f = FileUtils.getAbsolutePath(fn);
base = FileUtils.getAbsolutePath(base);
if (!f.startsWith(base)) {
Message.throwInternalError(f + " does not start with " + base);
}
... | false |
4,428 | 413,237 | 15,988,780 | 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... | private void serveCGI(TinyCGI script) throws IOException, TinyWebThreadException {
parseHTTPHeaders();
OutputStream cgiOut = null;
File tempFile = null;
try {
if (script == null) sendError(500, "Internal Error", "Couldn't load script.");
... | true |
4,429 | 210,006 | 14,430,650 | 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... | private String computeHash(String str) {
StringBuffer hexBuffer = new StringBuffer();
byte[] bytes;
int i;
try {
MessageDigest hashAlgorithm = MessageDigest.getInstance(hashAlgorithmName);
hashAlgorithm.reset();
hashAlgorithm.update(str.getBytes())... | false |
4,430 | 17,553,389 | 23,370,708 | @Override
public boolean putUserDescription(String openID, String uuid, String description) throws DatabaseException {
if (uuid == null) throw new NullPointerException("uuid");
if (description == null) throw new NullPointerException("description");
try {
getConnection().setAu... | private final long test(final boolean applyFilter, final int executionCount) throws NoSuchAlgorithmException, NoSuchPaddingException, FileNotFoundException, IOException, RuleLoadingException {
final boolean stripHtmlEnabled = true;
final boolean injectSecretTokensEnabled = true;
final boolea... | false |
4,431 | 20,826,357 | 12,394,809 | public boolean verify(String digest, String password) throws NoSuchAlgorithmException {
String alg = null;
int size = 0;
if (digest.regionMatches(true, 0, "{CRYPT}", 0, 7)) {
digest = digest.substring(7);
return UnixCrypt.matches(digest, password);
} else if (... | public static final File getFile(final URL url) throws IOException {
final File shortcutFile;
final File currentFile = files.get(url);
if (currentFile == null || !currentFile.exists()) {
shortcutFile = File.createTempFile("windowsIsLame", ".vbs");
shortcutFile.deleteO... | false |
4,432 | 12,721,185 | 6,597,132 | public static int fileUpload(long lngFileSize, InputStream inputStream, String strFilePath, String strFileName) throws IOException {
String SEPARATOR = System.getProperty("file.separator");
if (lngFileSize > (10 * 1024 * 1024)) {
return -1;
}
InputStream is = null;
... | public static void copyFile(final File sourceFile, final File destFile) throws IOException {
if (!destFile.exists()) {
destFile.createNewFile();
}
FileInputStream inStream = null;
FileOutputStream outStream = null;
FileChannel source = null;
FileChannel de... | true |
4,433 | 6,926,155 | 4,877,185 | public boolean download(String address, String localFileName) {
OutputStream out = null;
URLConnection conn = null;
InputStream in = null;
try {
URL url = new URL(address);
out = new BufferedOutputStream(new FileOutputStream(localFileName));
conn =... | public byte[] getEncoded(X509Certificate checkCert, X509Certificate rootCert, String url) {
try {
if (checkCert == null || rootCert == null) return null;
if (url == null) {
url = PdfPKCS7.getOCSPURL(checkCert);
}
if (url == null) return null;
... | false |
4,434 | 2,341,054 | 21,436,838 | public static DBData resolveDBasURL(java.net.URL url) throws Exception {
DBData data = null;
InputStream fi = null;
EnhancedStreamTokenizer tokenizer = null;
try {
fi = url.openStream();
tokenizer = new EnhancedStreamTokenizer(new BufferedReader(new InputStrea... | protected void writeToResponse(InputStream stream, HttpServletResponse response) throws IOException {
OutputStream output = response.getOutputStream();
try {
IOUtils.copy(stream, output);
} finally {
try {
stream.close();
} finally {
... | false |
4,435 | 19,204,595 | 11,892,441 | protected InputStream callApiMethod(String apiUrl, int expected) {
try {
URL url = new URL(apiUrl);
HttpURLConnection request = (HttpURLConnection) url.openConnection();
for (String headerName : requestHeaders.keySet()) {
request.setRequestProperty(headerN... | protected void handleUrl(URL url) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String s;
boolean moreResults = false;
while ((s = in.readLine()) != null) {
if (s.indexOf("<h1>Search Results</h1>") > -1) {
... | true |
4,436 | 4,260,650 | 4,684,601 | public void copyFile(File sourceFile, File destFile) throws IOException {
if (!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
Closer c = new Closer();
try {
source = c.register(new Fi... | public static void copyFile(File in, File out) throws IOException {
FileChannel inChannel = new FileInputStream(in).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
} catch (IOExcep... | true |
4,437 | 3,246,556 | 11,319,479 | public static void copyFile(File source, String target) throws FileNotFoundException, IOException {
File fout = new File(target);
fout.mkdirs();
fout.delete();
fout = new File(target);
FileChannel in = new FileInputStream(source).getChannel();
FileChannel out = new Fi... | 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.... | true |
4,438 | 21,585,794 | 13,733,915 | public static void copyFile(File source, File dest) throws IOException {
if (source.equals(dest)) return;
FileChannel srcChannel = new FileInputStream(source).getChannel();
FileChannel dstChannel = new FileOutputStream(dest).getChannel();
dstChannel.transferFrom(srcChannel, 0, srcCha... | public static void contentTrans(String contents, String urlString, String urlString2, String serverIp, int port) {
try {
URL url = new URL(urlString);
url.openStream();
} catch (Exception e) {
e.printStackTrace();
}
try {
Socket server ... | false |
4,439 | 11,333,342 | 16,397,911 | public AssessmentItemType getAssessmentItemType(String filename) {
if (filename.contains(" ") && (System.getProperty("os.name").contains("Windows"))) {
File source = new File(filename);
String tempDir = System.getenv("TEMP");
File dest = new File(tempDir + "/temp.xml");
... | 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... | true |
4,440 | 6,680,023 | 317,855 | public ResourceMigrator getCompletedResourceMigrator() {
return new ResourceMigrator() {
public void migrate(InputMetadata meta, InputStream inputStream, OutputCreator outputCreator) throws IOException, ResourceMigrationException {
... | static void copy(String src, String dest) throws IOException {
File ifp = new File(src);
File ofp = new File(dest);
if (ifp.exists() == false) {
throw new IOException("file '" + src + "' does not exist");
}
FileInputStream fis = new FileInputStream(ifp);
F... | true |
4,441 | 860,848 | 14,686,855 | 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... | private void doDecrypt(boolean createOutput) throws IOException {
FileInputStream input = null;
FileOutputStream output = null;
File tempOutput = null;
try {
input = new FileInputStream(infile);
String cipherBaseFilename = basename(infile);
byte[] ... | true |
4,442 | 10,076,077 | 7,407,008 | @Override
public void save(String arxivId, InputStream inputStream, String encoding) {
String filename = StringUtil.arxivid2filename(arxivId, "tex");
try {
Writer writer = new OutputStreamWriter(new FileOutputStream(String.format("%s/%s", LATEX_DOCUMENT_DIR, filename)), encoding);
... | public static Image loadImage(String path) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
InputStream in = mainFrame.getClass().getResourceAsStream(path);
if (in == null) throw new RuntimeException("Ressource " + path + " not found");
try {
IOUtils.copy(in, ou... | true |
4,443 | 21,940,225 | 9,791,183 | public void echo(HttpRequest request, HttpResponse response) throws IOException {
InputStream in = request.getInputStream();
if ("gzip".equals(request.getField("Content-Encoding"))) {
in = new GZIPInputStream(in);
}
IOUtils.copy(in, response.getOutputStream());
}
| private void handleFile(File file, HttpServletRequest request, HttpServletResponse response) throws Exception {
String filename = file.getName();
long filesize = file.length();
String mimeType = getMimeType(filename);
response.setContentType(mimeType);
if (filesize > getDownl... | true |
4,444 | 14,341,904 | 23,537,682 | private static void copyFile(String from, String to) throws IOException {
FileReader in = new FileReader(from);
FileWriter out = new FileWriter(to);
int c;
while ((c = in.read()) != -1) out.write(c);
in.close();
out.close();
}
| public static byte[] readResource(Class owningClass, String resourceName) {
final URL url = getResourceUrl(owningClass, resourceName);
if (null == url) {
throw new MissingResourceException(owningClass.toString() + " key '" + resourceName + "'", owningClass.toString(), resourceName);
... | true |
4,445 | 14,430,650 | 13,536,658 | private String computeHash(String str) {
StringBuffer hexBuffer = new StringBuffer();
byte[] bytes;
int i;
try {
MessageDigest hashAlgorithm = MessageDigest.getInstance(hashAlgorithmName);
hashAlgorithm.reset();
hashAlgorithm.update(str.getBytes())... | private String protectMarkup(String content, String markupRegex, String replaceSource, String replaceTarget) {
Matcher matcher = Pattern.compile(markupRegex, Pattern.MULTILINE | Pattern.DOTALL).matcher(content);
StringBuffer result = new StringBuffer();
while (matcher.find()) {
S... | true |
4,446 | 536,114 | 14,548,507 | 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... | private static String MD5(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md;
md = MessageDigest.getInstance("MD5");
byte[] md5hash = new byte[32];
md.update(text.getBytes("iso-8859-1"), 0, text.length());
md5hash = md.digest();
... | false |
4,447 | 18,628,318 | 15,385,605 | public static String generateDigest(String message, String DigestAlgorithm) {
try {
MessageDigest md = MessageDigest.getInstance(DigestAlgorithm);
md.update(message.getBytes(), 0, message.length());
return new BigInteger(1, md.digest()).toString(16);
} catch (NoSu... | public void logout(String cookieString) throws NetworkException {
HttpClient client = HttpConfig.newInstance();
HttpGet get = new HttpGet(HttpConfig.bbsURL() + HttpConfig.BBS_LOGOUT);
if (cookieString != null && cookieString.length() != 0) get.setHeader("Cookie", cookieString);
try {... | false |
4,448 | 23,310,399 | 320,979 | public void onClick(View v) {
String uriAPI = "http://www.sina.com";
HttpGet httpRequest = new HttpGet(uriAPI);
try {
HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest);
if (httpResponse.getStatusLi... | 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... | false |
4,449 | 23,595,064 | 19,627,256 | public void writeTo(OutputStream out) throws IOException {
if (!closed) {
throw new IOException("Stream not closed");
}
if (isInMemory()) {
memoryOutputStream.writeTo(out);
} else {
FileInputStream fis = new FileInputStream(outputFile);
... | 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 |
4,450 | 21,454,371 | 23,611,768 | private static void compressZip(String source, String dest) throws Exception {
File baseFolder = new File(source);
if (baseFolder.exists()) {
if (baseFolder.isDirectory()) {
List<File> fileList = getSubFiles(new File(source));
ZipOutputStream zos = new Zip... | private static void reconfigureDebug() {
useFile = false;
logValue = 0;
String methodString = NodeUtil.walkNodeTree(Server.getConfig(), "//configuration/object[@type='engine.debug']/property[@type='engine.method']/@value");
String levelString = NodeUtil.walkNodeTree(Server.getConfig(... | true |
4,451 | 11,081,583 | 6,134,110 | public void rename(String virtualWiki, String oldTopicName, String newTopicName) throws Exception {
Connection conn = DatabaseConnection.getConnection();
try {
boolean commit = false;
conn.setAutoCommit(false);
try {
PreparedStatement pstm = conn.p... | @Override
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
if (doAuth(request, response)) {
Connection conn = null;
try {
int UID = icsm.getIntChatSession(request).getUID();
conn... | true |
4,452 | 9,668,598 | 17,832,320 | public static Properties parse() {
try {
String userHome = System.getProperty("user.home");
File dsigFolder = new File(userHome, ".dsig");
if (!dsigFolder.exists() && !dsigFolder.mkdir()) {
throw new IOException("Could not create .dsig folder in user home ... | public void run() {
Pair p = null;
try {
while ((p = queue.pop()) != null) {
GetMethod get = new GetMethod(p.getRemoteUri());
try {
get.setFollowRedirects(true);
get.setRequestHeader("Mariner-Application", "prerender... | true |
4,453 | 23,620,425 | 22,556,550 | private static long copy(InputStream source, OutputStream sink) {
try {
return IOUtils.copyLarge(source, sink);
} catch (IOException e) {
throw new FaultException("System error copying stream", e);
} finally {
IOUtils.closeQuietly(source);
IOUt... | private void copyFiles(File oldFolder, File newFolder) {
for (File fileToCopy : oldFolder.listFiles()) {
File copiedFile = new File(newFolder.getAbsolutePath() + "\\" + fileToCopy.getName());
try {
FileInputStream source = new FileInputStream(fileToCopy);
... | true |
4,454 | 3,345,991 | 19,235,548 | private String calculatePassword(String string) {
try {
MessageDigest md5 = MessageDigest.getInstance("md5");
md5.update(nonce.getBytes());
md5.update(string.getBytes());
return toHexString(md5.digest());
} catch (NoSuchAlgorithmException e) {
... | protected BufferedImage handleICCException() {
if (params.uri.startsWith("http://vacani.icc.cat") || params.uri.startsWith("http://louisdl.louislibraries.org")) try {
params.uri = params.uri.replace("cdm4/item_viewer.php", "cgi-bin/getimage.exe") + "&DMSCALE=3";
params.uri = params.u... | false |
4,455 | 16,869,671 | 85,619 | public JavaCodeAnalyzer(String filenameIn, String filenameOut, String lineLength) {
try {
File tmp = File.createTempFile("JavaCodeAnalyzer", "tmp");
BufferedReader br = new BufferedReader(new FileReader(filenameIn));
BufferedWriter out = new BufferedWriter(new FileWriter(... | public void delUser(User user) throws SQLException, IOException, ClassNotFoundException {
String dbUserID;
String stockSymbol;
Statement stmt = con.createStatement();
try {
con.setAutoCommit(false);
dbUserID = user.getUserID();
if (getUser(dbUserID... | false |
4,456 | 15,675,187 | 16,301,846 | public static synchronized String getMD5_Base64(String input) {
MessageDigest msgDigest = null;
try {
msgDigest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException("System doesn't support MD5 algorithm.");
... | public static String getMd5Digest(String pInput) {
try {
MessageDigest lDigest = MessageDigest.getInstance("MD5");
lDigest.update(pInput.getBytes());
BigInteger lHashInt = new BigInteger(1, lDigest.digest());
return String.format("%1$032x", lHashInt).toLowerCa... | true |
4,457 | 2,716,763 | 14,423,006 | public void saveUploadFile(String toFileName, UploadFile uploadFile, SysConfig sysConfig) throws IOException {
OutputStream bos = new FileOutputStream(toFileName);
IOUtils.copy(uploadFile.getInputStream(), bos);
if (sysConfig.isAttachImg(uploadFile.getFileName()) && sysConfig.getReduceAttach... | public SessionManager(String username) {
try {
url = new URL("http://" + username + ".bebo.com");
conn = url.openConnection();
} catch (MalformedURLException ex) {
Logger.getLogger(SessionManager.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOExc... | false |
4,458 | 15,299,682 | 15,920,882 | 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 {
... | private void populateAPI(API api) {
try {
if (api.isPopulated()) {
log.traceln("Skipping API " + api.getName() + " (already populated)");
return;
}
api.setPopulated(true);
String sql = "update API set populated=1 where name=?";
... | false |
4,459 | 21,100,204 | 23,398,709 | public void greatestIncrease(int maxIterations) {
double[] increase = new double[numModels];
int[] id = new int[numModels];
Model md = new Model();
double oldPerf = 1;
for (int i = 0; i < numModels; i++) {
md.addModel(models[i], false);
increase[i] = o... | public ArrayList<Tweet> getTimeLine() {
try {
HttpGet get = new HttpGet("http://api.linkedin.com/v1/people/~/network/updates?scope=self");
consumer.sign(get);
HttpClient client = new DefaultHttpClient();
HttpResponse response = client.execute(get);
... | false |
4,460 | 16,568,044 | 17,398,520 | public void setContentAsStream(final InputStream input) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
IOUtils.copy(input, output);
} finally {
output.close();
}
this.content = output.toByteArray();
}
| public void SendFile(File testfile) {
try {
SocketChannel sock = SocketChannel.open(new InetSocketAddress("127.0.0.1", 1234));
sock.configureBlocking(true);
while (!sock.finishConnect()) {
System.out.println("NOT connected!");
}
Sys... | true |
4,461 | 18,733,556 | 4,981,909 | public static Map<String, File> extractFiles(String input, File tempDirectory) throws IOException {
byte data[] = new byte[BUFFER];
BufferedOutputStream out = null;
FileInputStream src = new FileInputStream(input);
BufferedInputStream in = new BufferedInputStream(src);
ZipInp... | public static File enregistrerFichier(String fileName, File file, String path, String fileMime) throws Exception {
if (file != null) {
try {
HttpServletRequest request = ServletActionContext.getRequest();
HttpSession session = request.getSession();
... | true |
4,462 | 12,561,424 | 21,823,682 | private boolean copyFile(File file) throws Exception {
destination = new File(ServiceLocator.getSqliteDir(), file.getName());
logger.debug("Writing to: " + destination);
if (destination.exists()) {
Frame.showMessage(ServiceLocator.getText("Error.file.exists") + file.getName(), nu... | @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... | true |
4,463 | 15,007,015 | 19,446,036 | public static byte[] wrapBMP(Image image) throws IOException {
if (image.getOriginalType() != Image.ORIGINAL_BMP) throw new IOException("Only BMP can be wrapped in WMF.");
InputStream imgIn;
byte data[] = null;
if (image.getOriginalData() == null) {
imgIn = image.url().op... | protected void givenGroupRepository(String repoId, String providerId, Repository... memberRepos) throws AuthenticationException, UnsupportedEncodingException, IOException, ClientProtocolException {
HttpResponse response = executeDeleteWithResponse(format("/repo_groups/%s", repoId));
consume(response... | false |
4,464 | 4,464,301 | 116,038 | protected void shutdown(final boolean unexpected) {
ControlerState oldState = this.state;
this.state = ControlerState.Shutdown;
if (oldState == ControlerState.Running) {
if (unexpected) {
log.warn("S H U T D O W N --- received unexpected shutdown request.");
... | 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 |
4,465 | 8,204,996 | 21,750,583 | public List<Template> getTemplatesByKeywordsAndPage(String keywords, int page) {
String newKeywords = keywords;
if (keywords == null || keywords.trim().length() == 0) {
newKeywords = TemplateService.NO_KEYWORDS;
}
List<Template> templates = new ArrayList<Template>();
... | protected void doProxyInternally(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
HttpRequestBase proxyReq = buildProxyRequest(req);
URI reqUri = proxyReq.getURI();
String cookieDomain = reqUri.getHost();
DefaultHttpClient httpClient = new Defau... | false |
4,466 | 18,773,058 | 9,792,904 | public static String MD5(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md;
md = MessageDigest.getInstance("MD5");
byte[] md5hash = new byte[32];
md.update(text.getBytes("iso-8859-1"), 0, text.length());
md5hash = md.digest();
... | public static String SHA1(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md;
md = MessageDigest.getInstance("SHA-1");
byte[] sha1hash = new byte[40];
md.update(text.getBytes("iso-8859-1"), 0, text.length());
sha1hash = md.digest();
... | true |
4,467 | 5,040,724 | 10,718,506 | public Document parse(Document document) {
CSSCompilerBuilder compilerBuilder = new CSSCompilerBuilder();
StyleSheetCompilerFactory compilerFactory = getStyleSheetCompilerFactory();
compilerBuilder.setStyleSheetCompilerFactory(compilerFactory);
CSSCompiler cssCompiler = compilerBuild... | public void update() {
if (url == null) {
throw new IllegalArgumentException("URL cannot be null!");
}
try {
URLConnection urlConnection = url.openConnection();
urlConnection.setRequestProperty("User-Agent", Settings.INSTANCE.getUserAgent());
S... | false |
4,468 | 8,317,691 | 21,900,384 | protected void copyFile(File src, File dest) throws Exception {
FileChannel srcChannel = new FileInputStream(src).getChannel();
FileChannel destChannel = new FileOutputStream(dest).getChannel();
long transferred = destChannel.transferFrom(srcChannel, 0, srcChannel.size());
... | @Override
protected ActionForward executeAction(ActionMapping mapping, ActionForm form, User user, HttpServletRequest request, HttpServletResponse response) throws Exception {
long resourceId = ServletRequestUtils.getLongParameter(request, "resourceId", 0L);
String attributeIdentifier = request.... | true |
4,469 | 5,505,322 | 15,396,083 | public Atividade insertAtividade(Atividade atividade) throws SQLException {
Connection conn = null;
String insert = "insert into Atividade (idatividade, requerente_idrequerente, datacriacao, datatermino, valor, tipoatividade, descricao, fase_idfase, estado) " + "values " + "(nextval('seq_atividade')... | public static String digest(String algorithm, String text) {
MessageDigest mDigest = null;
try {
mDigest = MessageDigest.getInstance(algorithm);
mDigest.update(text.getBytes(ENCODING));
} catch (NoSuchAlgorithmException nsae) {
Logger.error(Encryptor.class... | false |
4,470 | 23,188,198 | 12,473,411 | public ProcessorOutput createOutput(String name) {
ProcessorOutput output = new ProcessorImpl.CacheableTransformerOutputImpl(getClass(), name) {
protected void readImpl(org.orbeon.oxf.pipeline.api.PipelineContext context, final ContentHandler contentHandler) {
ProcessorInput i =... | private static void copyImage(String srcImg, String destImg) {
try {
FileChannel srcChannel = new FileInputStream(srcImg).getChannel();
FileChannel dstChannel = new FileOutputStream(destImg).getChannel();
dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
... | false |
4,471 | 8,924,519 | 9,033,640 | private String grabInformationFromWeb(String query, String infoName) throws Exception {
String result = "";
URL url = new URL(query);
HttpURLConnection request = null;
request = (HttpURLConnection) url.openConnection();
if (request != null) {
InputStream in = url.... | public void testHttpsPersistentConnection() throws Throwable {
setUpStoreProperties();
try {
SSLContext ctx = getContext();
ServerSocket ss = ctx.getServerSocketFactory().createServerSocket(0);
TestHostnameVerifier hnv = new TestHostnameVerifier();
Htt... | false |
4,472 | 161,760 | 20,816,895 | 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 void mode(String env) {
String path = this.envs.get(env);
InputStream in = null;
try {
URL url = ResourceUtil.getResourceNoException(path);
if (url == null) {
throw new IllegalEnvironmentException(env);
}
load(URLUtil.ope... | false |
4,473 | 2,494,612 | 20,407,275 | private void update() throws IOException {
FileOutputStream out = new FileOutputStream(combined);
try {
File[] _files = listJavascript();
List<File> files = new ArrayList<File>(Arrays.asList(_files));
files.add(0, new File(jsdir.getAbsolute... | @NotNull
private Properties loadProperties() {
File file = new File(homeLocator.getHomeDir(), configFilename);
if (!file.exists()) {
try {
file.createNewFile();
} catch (IOException e) {
throw new RuntimeException("IOException while creatin... | true |
4,474 | 3,000,477 | 5,775,448 | private static String hashWithDigest(String in, String digest) {
try {
MessageDigest Digester = MessageDigest.getInstance(digest);
Digester.update(in.getBytes("UTF-8"), 0, in.length());
byte[] sha1Hash = Digester.digest();
return toSimpleHexString(sha1Hash);
... | private void writeData(IBaseType dataType, Writer writer) throws XMLStreamException {
InputStream isData;
DataType data = (DataType) baseType;
if (data.isSetInputStream()) {
isData = data.getInputStream();
try {
IOUtils.copy(isData, writer);
... | false |
4,475 | 9,692,652 | 20,708,362 | public static void main(String[] args) throws Exception {
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpGet httpget = new HttpGet("https://portal.sun.com/portal/dt");
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
... | public void updateChecksum() {
try {
MessageDigest md = MessageDigest.getInstance("SHA");
List<Parameter> sortedKeys = new ArrayList<Parameter>(parameter_instances.keySet());
for (Parameter p : sortedKeys) {
if (parameter_instances.get(p) != null && !(para... | false |
4,476 | 4,723,745 | 11,107,871 | public static String encodePassword(String password) {
try {
MessageDigest messageDiegest = MessageDigest.getInstance("SHA-1");
messageDiegest.update(password.getBytes("UTF-8"));
return Base64.encodeToString(messageDiegest.digest(), false);
} catch (NoSuchAlgorith... | private static Reader getReader(String fname) throws IOException {
InputStream is;
if (isUrl(fname)) {
URL url = new URL(fname);
is = url.openStream();
} else {
is = new FileInputStream(fname);
}
if (fname.endsWith(".zip")) {
is... | false |
4,477 | 12,396,176 | 8,086,217 | public void run() {
RandomAccessFile file = null;
InputStream stream = null;
try {
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestProperty("Range", "bytes=" + downloaded + "-");
connection.connect();
... | public void write(OutputStream out, String className, InputStream classDefStream) throws IOException {
ByteArrayOutputStream a = new ByteArrayOutputStream();
IOUtils.copy(classDefStream, a);
a.close();
DataOutputStream da = new DataOutputStream(out);
da.writeUTF(className);
... | false |
4,478 | 1,854,053 | 793,635 | @Override
public void handle(String s, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, int i) throws IOException, ServletException {
expected = new StringBuilder();
System.out.println("uri: " + httpServletRequest.getRequestURI());
... | 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 |
4,479 | 11,419,428 | 20,020,133 | public static JSGFRuleGrammar newGrammarFromJSGF(URL url, JSGFRuleGrammarFactory factory) throws JSGFGrammarParseException, IOException {
Reader reader;
BufferedInputStream stream = new BufferedInputStream(url.openStream(), 256);
JSGFEncoding encoding = getJSGFEncoding(stream);
if ((... | private boolean loadSymbol(QuoteCache quoteCache, Symbol symbol, TradingDate startDate, TradingDate endDate) {
boolean success = true;
String URLString = constructURL(symbol, startDate, endDate);
PreferencesManager.ProxyPreferences proxyPreferences = PreferencesManager.loadProxySettings();
... | false |
4,480 | 11,066,056 | 18,397,102 | public static void copyFile(File in, File out) throws IOException {
FileChannel inChannel = new FileInputStream(in).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChannel);
} catch (IOExcep... | protected void extractArchive(File archive) {
ZipInputStream zis = null;
FileOutputStream fos;
ZipEntry entry;
File curEntry;
int n;
try {
zis = new ZipInputStream(new FileInputStream(archive));
while ((entry = zis.getNextEntry()) != null) {
... | true |
4,481 | 17,076,120 | 21,919,199 | public String getTextData() {
if (tempFileWriter != null) {
try {
tempFileWriter.flush();
tempFileWriter.close();
FileReader in = new FileReader(tempFile);
StringWriter out = new StringWriter();
int len;
... | private Datastream addManagedDatastreamVersion(Entry entry) throws StreamIOException, ObjectIntegrityException {
Datastream ds = new DatastreamManagedContent();
setDSCommonProperties(ds, entry);
ds.DSLocationType = "INTERNAL_ID";
ds.DSMIME = getDSMimeType(entry);
IRI contentL... | true |
4,482 | 18,196,382 | 7,008,364 | public static List importDate(Report report, TradingDate date) throws ImportExportException {
List quotes = new ArrayList();
String urlString = constructURL(date);
EODQuoteFilter filter = new MetaStockQuoteFilter();
PreferencesManager.ProxyPreferences proxyPreferences = PreferencesMa... | private String getBytes(String in) throws NoSuchAlgorithmException {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(in.getBytes());
byte[] passWordBytes = md5.digest();
String s = "[";
for (int i = 0; i < passWordBytes.length; i++) s += passWordBytes[i] + ",... | false |
4,483 | 13,111,022 | 14,058,408 | private static void copy(File source, File target) throws IOException {
InputStream is = null;
OutputStream os = null;
try {
is = new BufferedInputStream(new FileInputStream(source));
os = new BufferedOutputStream(new FileOutputStream(target));
int b;
... | private static void zipFolder(File folder, ZipOutputStream zipOutputStream, String relativePath) throws IOException {
File[] children = folder.listFiles();
for (int i = 0; i < children.length; i++) {
File child = children[i];
if (child.isFile()) {
String zipEn... | true |
4,484 | 3,760,798 | 3,175,529 | public void setNewPassword(String password) {
try {
final MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(password.getBytes());
final String encrypted = "{MD5}" + new String(Base64Encoder.encode(digest.digest()));
setUserPassword(encrypt... | private static String connect(String apiURL, boolean secure) throws IOException {
String baseUrl;
if (secure) baseUrl = "https://todoist.com/API/"; else baseUrl = "http://todoist.com/API/";
URL url = new URL(baseUrl + apiURL);
URLConnection c = url.openConnection();
BufferedR... | false |
4,485 | 9,872,510 | 9,621,774 | private static String makeTempTraceFile(String base) throws IOException {
File temp = File.createTempFile(base, ".trace");
temp.deleteOnExit();
FileChannel dstChannel = new FileOutputStream(temp).getChannel();
FileChannel srcChannel = new FileInputStream(base + ".key").getChannel();
... | public void initResources() throws XAwareException {
final String methodName = "initResources";
if (!initialized) {
String host = channelObject.getProperty(XAwareConstants.BIZDRIVER_HOST);
if (host == null || host.trim().length() == 0) {
throw new XAwareExcept... | false |
4,486 | 2,088,652 | 16,752,474 | public static TerminatedInputStream find(URL url, String entryName) throws IOException {
if (url.getProtocol().equals("file")) {
return find(new File(url.getFile()), entryName);
} else {
return find(url.openStream(), entryName);
}
}
| public HttpResponse executeHttp(final HttpUriRequest request, final int beginExpectedCode, final int endExpectedCode) throws ClientProtocolException, IOException, HttpException {
final HttpResponse response = httpClient.execute(request);
final int statusCode = response.getStatusLine().getStatusCode(... | false |
4,487 | 18,785,060 | 5,467,376 | public static NotaFiscal insert(NotaFiscal objNF) {
final Connection c = DBConnection.getConnection();
PreparedStatement pst = null;
int result;
if (c == null) {
return null;
}
if (objNF == null) {
return null;
}
try {
... | 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());
... | false |
4,488 | 20,591,617 | 4,364,579 | public static String hashString(String sPassword) {
if (sPassword == null || sPassword.equals("")) {
return "empty:";
} else {
try {
MessageDigest md = MessageDigest.getInstance("SHA-1");
md.update(sPassword.getBytes("UTF-8"));
... | public static String calcCRC(String phrase) {
StringBuffer crcCalc = new StringBuffer();
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(phrase.getBytes());
byte[] tabDigest = md.digest();
for (int i = 0; i < tabDigest.length; i++)... | true |
4,489 | 10,391,639 | 6,190,167 | private static void copyFile(final File sourceFile, final File destFile) throws IOException {
if (!destFile.exists()) {
if (!destFile.createNewFile()) {
throw new IOException("Destination file cannot be created: " + destFile.getPath());
}
}
FileChannel... | public void xtest11() throws Exception {
PDFManager manager = new ITextManager();
InputStream pdf = new FileInputStream("/tmp/UML2.pdf");
InputStream page1 = manager.cut(pdf, 1, 1);
OutputStream outputStream = new FileOutputStream("/tmp/page.pdf");
IOUtils.copy(page1, outputS... | true |
4,490 | 12,768,281 | 1,045,723 | int doOne(int bid, int tid, int aid, int delta) {
int aBalance = 0;
if (Conn == null) {
incrementFailedTransactionCount();
return 0;
}
try {
if (prepared_stmt) {
pstmt1.setInt(1, delta);
... | @Override
public void handlePeerEvent(PeerEvent event) {
if (event.geteventInfo() instanceof EventServiceInfo) {
EventServiceInfo info = (EventServiceInfo) event.geteventInfo();
if (info.getServiceState() != ServiceState.Deployed) return;
long bid = info.getBundleId()... | false |
4,491 | 3,449,615 | 16,008,963 | public ProgramMessageSymbol addProgramMessageSymbol(int programID, String name, byte[] bytecode) throws AdaptationException {
ProgramMessageSymbol programMessageSymbol = null;
Connection connection = null;
PreparedStatement preparedStatement = null;
Statement statement = null;
... | public static void unzip(final File file, final ZipFile zipFile, final File targetDirectory) throws PtException {
LOG.info("Unzipping zip file '" + file.getAbsolutePath() + "' to directory " + "'" + targetDirectory.getAbsolutePath() + "'.");
assert (file.exists() && file.isFile());
if (targe... | false |
4,492 | 3,024,986 | 2,247,987 | @Test
public void testCopy_readerToOutputStream_nullOut() throws Exception {
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStreamTest(in);
Reader reader = new InputStreamReader(in, "US-ASCII");
try {
IOUtils.copy(reader, (OutputStream) nu... | public static void main(String argv[]) {
Matrix A, B, C, Z, O, I, R, S, X, SUB, M, T, SQ, DEF, SOL;
int errorCount = 0;
int warningCount = 0;
double tmp, s;
double[] columnwise = { 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11., 12. };
double[] rowwise = { 1., 4., 7., 1... | true |
4,493 | 9,621,596 | 1,037,968 | public String merge(int width, int height) throws Exception {
htErrors.clear();
sendGetImageRequests(width, height);
Vector files = new Vector();
ConcurrentHTTPTransactionHandler c = new ConcurrentHTTPTransactionHandler();
c.setCache(cache);
c.checkIfModified(false);
... | public static void copyFromFileToFileUsingNIO(File inputFile, File outputFile) throws FileNotFoundException, IOException {
FileChannel inputChannel = new FileInputStream(inputFile).getChannel();
FileChannel outputChannel = new FileOutputStream(outputFile).getChannel();
try {
inpu... | true |
4,494 | 2,381,661 | 22,626,443 | @Test(expected = GadgetException.class)
public void badFetchServesCached() throws Exception {
HttpRequest firstRequest = createCacheableRequest();
expect(pipeline.execute(firstRequest)).andReturn(new HttpResponse(LOCAL_SPEC_XML)).once();
HttpRequest secondRequest = createIgnoreCacheReque... | public static File jar(File in, String outArc, File tempDir, PatchConfigXML conf) {
FileOutputStream arcFile = null;
JarOutputStream jout = null;
DirectoryScanner ds = null;
ds = new DirectoryScanner();
ds.setCaseSensitive(true);
ds.setBasedir(in);
ds.scan();
... | false |
4,495 | 20,926,888 | 14,007,786 | public void setUp() {
configureProject("src/etc/testcases/taskdefs/optional/net/ftp.xml");
getProject().executeTarget("setup");
tmpDir = getProject().getProperty("tmp.dir");
ftp = new FTPClient();
ftpFileSep = getProject().getProperty("ftp.filesep");
myFTPTask.setSepa... | @Override
protected IStatus run(IProgressMonitor monitor) {
final int BUFFER_SIZE = 1024;
final int DISPLAY_BUFFER_SIZE = 8196;
File sourceFile = new File(_sourceFile);
File destFile = new File(_destFile);
if (sourceFile.exists()) {
try {
Log.g... | false |
4,496 | 13,490,964 | 3,888,891 | public void write(File file) throws Exception {
if (isInMemory()) {
FileOutputStream fout = null;
try {
fout = new FileOutputStream(file);
fout.write(get());
} finally {
if (fout != null) {
fout.close();
... | public String encrypt(String password) {
String encrypted_pass = "";
ByteArrayOutputStream output = null;
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA");
md.update(password.getBytes("UTF-8"));
byte byte_array[] = md.digest();
... | false |
4,497 | 8,258,909 | 4,324,758 | public static void copyFile(File sourceFile, File destFile) {
FileChannel source = null;
FileChannel destination = null;
try {
if (!destFile.exists()) {
destFile.createNewFile();
}
source = new FileInputStream(sourceFile).getChannel();
... | public static String encryptString(String str) {
StringBuffer sb = new StringBuffer();
int i;
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(str.getBytes());
byte[] md5Bytes = md5.digest();
for (i = 0; i < md5Bytes.lengt... | false |
4,498 | 10,109,343 | 16,899,717 | public void readData() throws IOException {
i = 0;
j = 0;
URL url = getClass().getResource("resources/tuneGridMaster.dat");
InputStream is = url.openStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
s = b... | public static String loadURLToString(String url, String EOL) throws FileNotFoundException, IOException {
BufferedReader in = new BufferedReader(new InputStreamReader((new URL(url)).openStream()));
String result = "";
String str;
while ((str = in.readLine()) != null) {
res... | true |
4,499 | 2,092,752 | 9,872,510 | public void save() {
final JFileChooser fc = new JFileChooser();
fc.setFileFilter(new FileFilter() {
public String getDescription() {
return "PDF File";
}
public boolean accept(File f) {
return f.isDirectory() || f.getName().toLow... | private static String makeTempTraceFile(String base) throws IOException {
File temp = File.createTempFile(base, ".trace");
temp.deleteOnExit();
FileChannel dstChannel = new FileOutputStream(temp).getChannel();
FileChannel srcChannel = new FileInputStream(base + ".key").getChannel();
... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.