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 |
|---|---|---|---|---|---|
5,400 | 10,960,896 | 18,796,914 | public static void executeUpdate(Database db, String... statements) throws SQLException {
Connection con = null;
Statement stmt = null;
try {
con = getConnection(db);
con.setAutoCommit(false);
stmt = con.createStatement();
for (String statement... | public String getPloidy(String source) {
StringBuilder ploidyHtml = new StringBuilder();
String hyperdiploidyUrl = customParameters.getHyperdiploidyUrl();
String urlString = hyperdiploidyUrl + "?source=" + source;
URL url = null;
try {
url = new URL(urlString);
... | false |
5,401 | 653,083 | 21,907,699 | public Configuration(URL url) {
InputStream in = null;
try {
load(in = url.openStream());
} catch (Exception e) {
throw new RuntimeException("Could not load configuration from " + url, e);
} finally {
if (in != null) {
try {
... | public void getFile(OutputStream output, Fragment fragment) throws Exception {
Assert.Arg.notNull(output, "output");
Assert.Arg.notNull(fragment, "fragment");
Assert.Arg.notNull(fragment.getId(), "fragment.getId()");
if (this.delegate != null) {
this.delegate.getFile(outp... | false |
5,402 | 76,427 | 1,908,212 | public static void doVersionCheck(View view) {
view.showWaitCursor();
try {
URL url = new URL(jEdit.getProperty("version-check.url"));
InputStream in = url.openStream();
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
String line;
... | public static CMLUnitList createUnitList(URL url) throws IOException, CMLException {
Document dictDoc = null;
InputStream in = null;
try {
in = url.openStream();
dictDoc = new CMLBuilder().build(in);
} catch (NullPointerException e) {
e.printStackT... | false |
5,403 | 12,626,920 | 7,068,381 | public void xtestFile2() throws Exception {
InputStream inputStream = new FileInputStream(IOTest.FILE);
OutputStream outputStream = new FileOutputStream("C:/Temp/testFile2.mp4");
IOUtils.copy(inputStream, outputStream);
inputStream.close();
outputStream.close();
}
| public static void main(String argv[]) {
try {
if (argv.length != 1 && argv.length != 3) {
usage();
System.exit(1);
}
URL url = new URL(argv[0]);
URLConnection conn;
conn = url.openConnection();
if (conn.... | false |
5,404 | 3,809,797 | 982,287 | protected void addAssetResources(MimeMultipart pkg, MarinerPageContext context) throws PackagingException {
boolean includeFullyQualifiedURLs = context.getBooleanDevicePolicyValue("protocol.mime.fully.qualified.urls");
MarinerRequestContext requestContext = context.getRequestContext();
Appli... | private void writeFile(FileInputStream inFile, FileOutputStream outFile) throws IOException {
byte[] buf = new byte[2048];
int read;
while ((read = inFile.read(buf)) > 0 && !stopped) outFile.write(buf, 0, read);
inFile.close();
}
| false |
5,405 | 22,221,713 | 727,183 | private void copyFile(String sourceFilename, String targetFilename) throws IOException {
File source = new File(sourceFilename);
File target = new File(targetFilename);
InputStream in = new FileInputStream(source);
OutputStream out = new FileOutputStream(target);
byte[] buf =... | 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... | true |
5,406 | 12,394,809 | 22,769,774 | 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... | public static void copyFile(File src, File dest) throws IOException {
FileInputStream fis = new FileInputStream(src);
FileOutputStream fos = new FileOutputStream(dest);
java.nio.channels.FileChannel channelSrc = fis.getChannel();
java.nio.channels.FileChannel channelDest = fos.getCha... | false |
5,407 | 5,498,222 | 4,047,586 | public static void copyFile(String inputFile, String outputFile) throws IOException {
FileInputStream fis = new FileInputStream(inputFile);
FileOutputStream fos = new FileOutputStream(outputFile);
for (int b = fis.read(); b != -1; b = fis.read()) fos.write(b);
fos.close();
fi... | public static void toValueSAX(Property property, Value value, int valueType, ContentHandler contentHandler, AttributesImpl na, Context context) throws SAXException, RepositoryException {
na.clear();
String _value = null;
switch(valueType) {
case PropertyType.DATE:
... | true |
5,408 | 3,962,795 | 6,544,431 | public static String Sha1(String s) {
try {
MessageDigest md = MessageDigest.getInstance("SHA-1");
byte[] hash = new byte[40];
md.update(s.getBytes("iso-8859-1"), 0, s.length());
hash = md.digest();
return toHex(hash);
} catch (Exception e)... | protected static void clearTables() throws SQLException {
Connection conn = null;
Statement stmt = null;
try {
conn = FidoDataSource.getConnection();
conn.setAutoCommit(false);
stmt = conn.createStatement();
ClearData.clearTables(stmt);
... | false |
5,409 | 742,572 | 19,267,856 | 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 updateTableData(Connection dest, TableMetaData tableMetaData, Row r) throws Exception {
PreparedStatement ps = null;
try {
dest.setAutoCommit(false);
String sql = "UPDATE " + tableMetaData.getSchema() + "." + tableMetaData.getTableName() + " SET ";
... | true |
5,410 | 6,190,161 | 2,439,668 | public void xtest2() throws Exception {
InputStream input1 = new FileInputStream("C:/Documentos/j931_01.pdf");
InputStream input2 = new FileInputStream("C:/Documentos/j931_02.pdf");
InputStream tmp = new ITextManager().merge(new InputStream[] { input1, input2 });
FileOutputStream out... | public void run() {
try {
textUpdater.start();
int cnt;
byte[] buf = new byte[4096];
File file = null;
ZipInputStream zis = new ZipInputStream(new FileInputStream(new File(filename)));
ZipEntry ze = zis.getNextEntry();
FileO... | true |
5,411 | 10,480,051 | 2,857,623 | 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... | private void copy(File src, File dest, String name) {
File srcFile = new File(src, name);
File destFile = new File(dest, name);
if (destFile.exists()) {
if (destFile.lastModified() == srcFile.lastModified()) return;
destFile.delete();
}
FileChannel in ... | false |
5,412 | 333,109 | 4,277,520 | public static void doVersionCheck(View view) {
view.showWaitCursor();
try {
URL url = new URL(jEdit.getProperty("version-check.url"));
InputStream in = url.openStream();
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
String line;
... | private void loadMap(URI uri) throws IOException {
BufferedReader reader = null;
InputStream stream = null;
try {
URL url = uri.toURL();
stream = url.openStream();
if (url.getFile().endsWith(".gz")) {
stream = new GZIPInputStream(stream);
... | true |
5,413 | 8,539,546 | 17,727,663 | 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... | private static void copy(String sourceName, String destName) throws IOException {
File source = new File(sourceName);
File dest = new File(destName);
FileChannel in = null, out = null;
try {
in = new FileInputStream(source).getChannel();
out = new FileOutputSt... | true |
5,414 | 20,436,817 | 16,822,378 | private void copyXsl(File aTargetLogDir) {
Trace.println(Trace.LEVEL.UTIL, "copyXsl( " + aTargetLogDir.getName() + " )", true);
if (myXslSourceDir == null) {
return;
}
File[] files = myXslSourceDir.listFiles();
for (int i = 0; i < files.length; i++) {
... | public String descargarArchivo(String miArchivo, String nUsuario) {
try {
URL url = new URL(conf.Conf.descarga + nUsuario + "/" + miArchivo);
URLConnection urlCon = url.openConnection();
System.out.println(urlCon.getContentType());
InputStream is = urlCon.getI... | false |
5,415 | 19,758,418 | 14,782,656 | public static String post(String strUrl, String data) throws Exception {
URL url = new URL(strUrl);
final String method = "POST";
final String host = url.getHost();
final String contentType = "application/x-www-form-urlencoded";
final int contentLength = getContentLength(data... | private static Long statusSWGCraftTime() {
long current = System.currentTimeMillis() / 1000L;
if (current < (previousStatusCheck + SWGCraft.STATUS_CHECK_DELAY)) return previousStatusTime;
URL url = null;
try {
synchronized (previousStatusTime) {
if (curren... | false |
5,416 | 6,190,160 | 13,616,724 | public void xtest1() throws Exception {
InputStream input = new FileInputStream("C:/Documentos/j931_01.pdf");
InputStream tmp = new ITextManager().cut(input, 3, 8);
FileOutputStream output = new FileOutputStream("C:/temp/split.pdf");
IOUtils.copy(tmp, output);
input.close();
... | public void write(File file) throws Exception {
if (medooFile != null) {
if (!medooFile.renameTo(file)) {
BufferedInputStream in = null;
BufferedOutputStream out = null;
try {
in = new BufferedInputStream(new FileInputStream(med... | true |
5,417 | 16,891,145 | 6,729,311 | public static byte[] expandPasswordToKeySSHCom(String password, int keyLen) {
try {
if (password == null) {
password = "";
}
MessageDigest md5 = MessageDigest.getInstance("MD5");
int digLen = md5.getDigestLength();
byte[] buf = new ... | private void getRandomGUID(boolean secure) {
MessageDigest md5 = null;
StringBuffer sbValueBeforeMD5 = new StringBuffer();
try {
md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
System.out.println("Error: " + e);
}
... | true |
5,418 | 19,178,250 | 21,075,055 | public static String createMD5(String str) {
String sig = null;
String strSalt = str + sSalt;
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(strSalt.getBytes(), 0, strSalt.length());
byte byteData[] = md5.digest();
Strin... | 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);... | true |
5,419 | 17,402,775 | 7,669,917 | 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);
... | public void insertStringInFile(String file, String textToInsert, long fromByte, long toByte) throws Exception {
String tmpFile = file + ".tmp";
BufferedInputStream in = null;
BufferedOutputStream out = null;
long byteCount = 0;
try {
in = new BufferedInputStream(n... | true |
5,420 | 19,687,458 | 14,661,394 | public void testMemberSeek() throws IOException {
GZIPMembersInputStream gzin = new GZIPMembersInputStream(new ByteArrayInputStream(allfour_gz));
gzin.setEofEachMember(true);
gzin.compressedSeek(noise1k_gz.length + noise32k_gz.length);
int count2 = IOUtils.copy(gzin, new NullOutputSt... | public void run() {
XmlFilesFilter filter = new XmlFilesFilter();
String pathTemp = Settings.get("vo_store.databaseMetaCollection");
String sectionName = pathTemp.substring(1, pathTemp.indexOf("/", 2));
String templateName = VOAccess.getElementByName(settingsDB, "TEMPLATE", sectionNa... | true |
5,421 | 2,687,278 | 16,506,848 | @Override
protected void copy(InputStream inputs, OutputStream outputs) throws IOException {
if (outputs == null) {
throw new NullPointerException();
}
if (inputs == null) {
throw new NullPointerException();
}
ZipOutputStream zipoutputs = null;
... | public static void copy(File src, File dst) throws IOException {
FileChannel srcChannel = new FileInputStream(src).getChannel();
FileChannel dstChannel = new FileOutputStream(dst).getChannel();
try {
dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
} finally {
... | true |
5,422 | 20,282,676 | 20,491,150 | public boolean processFtp(String serverIp, int port, String user, String password, String synchrnPath, String filePath, File[] uploadFile) throws Exception {
boolean upload = false;
try {
FTPClient ftpClient = new FTPClient();
ftpClient.setControlEncoding("euc-kr");
... | private void retrieveClasses(URL url, Map<String, T> cmds) {
try {
String resource = URLDecoder.decode(url.getPath(), "UTF-8");
File directory = new File(resource);
if (directory.exists()) {
String[] files = directory.list();
for (String fi... | false |
5,423 | 398,778 | 2,426,161 | public static boolean downloadFile(String url, String destination) throws Exception {
BufferedInputStream bi = null;
BufferedOutputStream bo = null;
File destfile;
byte BUFFER[] = new byte[100];
java.net.URL fileurl;
URLConnection conn;
fileurl = new java.net.... | public void readURL(URL url) throws IOException, ParserConfigurationException, SAXException {
URLConnection connection;
if (proxy == null) {
connection = url.openConnection();
} else {
connection = url.openConnection(proxy);
}
connection.setConnectTime... | false |
5,424 | 6,417,996 | 14,537,899 | public void testLocalUserAccountLocalRemoteRoles() throws SQLException {
Statement st = null;
Connection authedCon = null;
try {
saSt.executeUpdate("CREATE USER tlualrr PASSWORD 'wontuse'");
saSt.executeUpdate("GRANT role3 TO tlualrr");
saSt.executeUpdate(... | private HttpsURLConnection setUpConnection(URL url) throws NoSuchAlgorithmException, KeyManagementException, IOException {
HttpsURLConnection openConnection = (HttpsURLConnection) url.openConnection();
openConnection.setAllowUserInteraction(true);
openConnection.setUseCaches(false);
... | false |
5,425 | 3,788,596 | 8,983,114 | 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... | @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... | true |
5,426 | 18,942,525 | 4,259,286 | public void updateUserInfo(AuthSession authSession, AuthUserExtendedInfo infoAuth) {
log.info("Start update auth");
PreparedStatement ps = null;
DatabaseAdapter db = null;
try {
db = DatabaseAdapter.getInstance();
String sql = "update WM_AUTH_USER " + "set " +... | protected List webservice(URL url, List locations, boolean followRedirect) throws GeoServiceException {
long start = System.currentTimeMillis();
int rowCount = 0, hitCount = 0;
try {
HttpURLConnection con;
try {
con = (HttpURLConnection) url.openConnec... | false |
5,427 | 8,211,013 | 6,121,196 | protected byte[] computeHash() {
try {
final MessageDigest inputHash = MessageDigest.getInstance("SHA");
inputHash.update(bufferFileData().getBytes());
return inputHash.digest();
} catch (final NoSuchAlgorithmException nsae) {
lastException = nsae;
... | public static boolean saveMap(LWMap map, boolean saveAs, boolean export) {
Log.info("saveMap: " + map);
GUI.activateWaitCursor();
if (map == null) return false;
File file = map.getFile();
int response = -1;
if (map.getSaveFileModelVersion() == 0) {
final O... | false |
5,428 | 15,873,054 | 9,481,276 | public static final long copyFile(final File srcFile, final File dstFile, final long cpySize) throws IOException {
if ((null == srcFile) || (null == dstFile)) return (-1L);
final File dstFolder = dstFile.getParentFile();
if ((!dstFolder.exists()) && (!dstFolder.mkdirs())) throw new IOExcepti... | public void save(InputStream is) throws IOException {
File dest = Config.getDataFile(getInternalDate(), getPhysMessageID());
OutputStream os = null;
try {
os = new FileOutputStream(dest);
IOUtils.copyLarge(is, os);
} finally {
IOUtils.closeQuietly(... | true |
5,429 | 10,516,730 | 23,283,258 | public final boolean login(String user, String pass) {
if (user == null || pass == null) return false;
connectionInfo.setData("com.tensegrity.palojava.pass#" + user, pass);
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(pass.getBytes());
... | public String login(HttpSession callingSession, String username, String password) {
String token = null;
String customer = null;
int timeoutInSeconds = 0;
HashSet<Integer> tileProviderIds = new HashSet<Integer>();
boolean bLoginOk = false;
String dbPassword = (String)... | true |
5,430 | 10,689,659 | 16,351,775 | public static void copyFile(File fromFile, File toFile) throws OWFileCopyException {
try {
FileChannel src = new FileInputStream(fromFile).getChannel();
FileChannel dest = new FileOutputStream(toFile).getChannel();
dest.transferFrom(src, 0, src.size());
src.cl... | 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 |
5,431 | 17,258,629 | 5,596,825 | private void checkRoundtrip(byte[] content) throws Exception {
InputStream in = new ByteArrayInputStream(content);
ByteArrayOutputStream out = new ByteArrayOutputStream();
CodecUtil.encodeQuotedPrintableBinary(in, out);
in = new QuotedPrintableInputStream(new ByteArrayInputStream(out... | public ZIPSignatureService(InputStream documentInputStream, SignatureFacet signatureFacet, OutputStream documentOutputStream, RevocationDataService revocationDataService, TimeStampService timeStampService, String role, IdentityDTO identity, byte[] photo, DigestAlgo signatureDigestAlgo) throws IOException {
... | true |
5,432 | 9,059,012 | 22,568,530 | public static InputStream downloadStream(URL url) {
InputStream inputStream = null;
try {
URLConnection urlConnection = url.openConnection();
if (urlConnection instanceof HttpURLConnection) {
HttpURLConnection httpURLConnection = (HttpURLConnection) urlConnect... | private InputStream callService(String text) {
InputStream in = null;
try {
URL url = new URL(SERVLET_URL);
URLConnection conn = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) conn;
httpConn.setRequestMethod("POST");
... | false |
5,433 | 4,960,419 | 13,745,786 | public static boolean writeFileByChars(Reader pReader, File pFile, boolean pAppend) {
boolean flag = false;
try {
FileWriter fw = new FileWriter(pFile, pAppend);
IOUtils.copy(pReader, fw);
fw.flush();
fw.close();
pReader.close();
... | private String fetchHtml(URL url) throws IOException {
URLConnection connection;
if (StringUtils.isNotBlank(proxyHost) && proxyPort != null) {
Proxy proxy = new Proxy(Proxy.Type.HTTP, InetSocketAddress.createUnresolved(proxyHost, proxyPort));
connection = url.openConnection(p... | false |
5,434 | 2,711,645 | 21,280,043 | public static boolean decodeFileToFile(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 createWar() throws IOException, XMLStreamException {
String appName = this.fileout.getName();
int i = appName.indexOf(".");
if (i != -1) appName = appName.substring(0, i);
ZipOutputStream zout = new ZipOutputStream(new FileOutputStream(this.fileout));
{
... | true |
5,435 | 14,416,222 | 4,071,092 | private boolean subtitleDownload(Movie movie, File movieFile, File subtitleFile) {
try {
String ret;
String xml;
String moviehash = getHash(movieFile);
String moviebytesize = String.valueOf(movieFile.length());
xml = generateXMLRPCSS(moviehash, mov... | public static String harvestForUser(Node userNode, String alias, Boolean all) {
FTPClient client = new FTPClient();
OutputStream outStream = null;
Calendar filterCal = Calendar.getInstance();
filterCal.set(Calendar.DAY_OF_MONTH, filterCal.get(Calendar.DAY_OF_MONTH) - 1);
Date... | false |
5,436 | 19,824,066 | 1,989,227 | public boolean visar() throws SQLException, ClassNotFoundException, Exception {
Connection conn = null;
PreparedStatement ps = null;
Date fechaSystem = new Date();
DateFormat aaaammdd = new SimpleDateFormat("yyyyMMdd");
DateFormat hhmmss = new SimpleDateFormat("HHmmss");
... | public void anular() throws SQLException, ClassNotFoundException, Exception {
Connection conn = null;
PreparedStatement ms = null;
try {
conn = ToolsBD.getConn();
conn.setAutoCommit(false);
String sentencia_delete = "DELETE FROM BZOFRENT " + " WHERE REN_OF... | true |
5,437 | 23,525,240 | 15,520,770 | private void gravaOp(Vector<?> op) {
PreparedStatement ps = null;
String sql = null;
ResultSet rs = null;
int seqop = 0;
Date dtFabrOP = null;
try {
sql = "SELECT MAX(SEQOP) FROM PPOP WHERE CODEMP=? AND CODFILIAL=? AND CODOP=?";
ps = con.prepar... | public void writeConfigurationFile() throws IOException, ComponentException {
SystemConfig config = parent.getParentSystem().getConfiguration();
File original = config.getLocation();
File backup = new File(original.getParentFile(), original.getName() + "." + System.currentTimeMillis());
... | false |
5,438 | 18,731,109 | 21,266,147 | 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.... | public void execute() {
File sourceFile = new File(oarfilePath);
File destinationFile = new File(deploymentDirectory + File.separator + sourceFile.getName());
try {
FileInputStream fis = new FileInputStream(sourceFile);
FileOutputStream fos = new FileOutputStream(dest... | true |
5,439 | 11,664,406 | 19,462,026 | public void doGet(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
String version = req.getParameter("version");
String cdn = req.getParameter("cdn");
String dependencies = req.getParameter("dependencies");
String optimize = req.getParameter("op... | public void copy(final File source, final File dest) throws IOException {
final FileInputStream in = new FileInputStream(source);
try {
final FileOutputStream out = new FileOutputStream(dest);
try {
final FileChannel inChannel = in.getChannel();
... | false |
5,440 | 18,773,782 | 9,385,030 | @Override
public void render(IContentNode contentNode, Request req, Response resp, Application app, ServerInfo serverInfo) {
Node fileNode = contentNode.getNode();
try {
Node res = fileNode.getNode("jcr:content");
if (checkLastModified(res, req.getServletRequset(), resp.g... | public static void main(String[] args) throws Exception {
long start = System.currentTimeMillis();
XSLTBuddy buddy = new XSLTBuddy();
buddy.parseArgs(args);
XSLTransformer transformer = new XSLTransformer();
if (buddy.templateDir != null) {
transformer.setTemplate... | true |
5,441 | 20,913,493 | 1,944,560 | public static void copy(File src, File dest) throws IOException {
log.info("Copying " + src.getAbsolutePath() + " to " + dest.getAbsolutePath());
if (!src.exists()) throw new IOException("File not found: " + src.getAbsolutePath());
if (!src.canRead()) throw new IOException("Source not readab... | 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 |
5,442 | 13,139,266 | 6,273,110 | public static String encripta(String senha) throws GCIException {
LOGGER.debug(INICIANDO_METODO + "encripta(String)");
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(senha.getBytes());
BASE64Encoder encoder = new BASE64Encoder();
... | public void addStadium(Stadium stadium) throws StadiumException {
Connection conn = ConnectionManager.getManager().getConnection();
if (findStadiumBy_N_C(stadium.getName(), stadium.getCity()) != -1) throw new StadiumException("Stadium already exists");
try {
PreparedStatement stm... | false |
5,443 | 7,902,811 | 9,223,155 | protected long incrementInDatabase(Object type) {
long current_value;
long new_value;
String entry;
if (global_entry != null) entry = global_entry; else throw new UnsupportedOperationException("Named key generators are not yet supported.");
String lkw = (String) properties.ge... | private String checkForUpdate() {
InputStream is = null;
try {
URL url = new URL(CHECK_UPDATES_URL);
try {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("User-Agent", "TinyLaF");
Obje... | false |
5,444 | 7,861,020 | 8,085,496 | private void writeToFile(Body b, File mime4jFile) throws FileNotFoundException, IOException {
if (b instanceof TextBody) {
String charset = CharsetUtil.toJavaCharset(b.getParent().getCharset());
if (charset == null) {
charset = "ISO8859-1";
}
O... | public MemoryBinaryBody(InputStream is) throws IOException {
TempPath tempPath = TempStorage.getInstance().getRootTempPath();
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOUtils.copy(is, out);
out.close();
tempFile = out.toByteArray();
}
| true |
5,445 | 7,406,942 | 13,421,720 | private void getXMLData() {
String result = null;
URL url = null;
URLConnection conn = null;
BufferedReader rd = null;
StringBuffer sb = new StringBuffer();
String line;
try {
url = new URL(this.url);
conn = url.openConnection();
... | public static String download(String address, String outputFolder) {
URL url = null;
String fileName = "";
try {
url = new URL(address);
System.err.println("Indirizzo valido!");
} catch (MalformedURLException ex) {
System.err.println("Indirizzo non... | false |
5,446 | 15,700,438 | 16,280,341 | private void getViolationsReportByProductOfferIdYearMonth() throws IOException {
String xmlFile8Send = System.getenv("SLASOI_HOME") + System.getProperty("file.separator") + "Integration" + System.getProperty("file.separator") + "soap" + System.getProperty("file.separator") + "getViolationsReportByProductOff... | private void mergeInDefaultMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
try {
String surl = AutoplotUtil.getProperty("autoplot.default.bookmarks", "http://www.autoplot.org/data/demos.xml");
URL url = new URL(surl);
Document doc = AutoplotUtil.readDoc(url.open... | false |
5,447 | 6,082,588 | 5,204,087 | protected void processAnnotationsJndi(URL url) {
try {
URLConnection urlConn = url.openConnection();
DirContextURLConnection dcUrlConn;
if (!(urlConn instanceof DirContextURLConnection)) {
sm.getString("contextConfig.jndiUrlNotDirContextConn", url);
... | protected boolean createFile(final IProject project, final IProgressMonitor monitor, final Template templ, final String sourceUrl, final String destFile, final boolean isBinary) throws IOException, CoreException {
URL url;
url = new URL(sourceUrl);
final URLConnection con = url.openConnectio... | false |
5,448 | 14,689,323 | 14,876,163 | 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 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... | false |
5,449 | 7,142,335 | 725,986 | public String getHTTPContent(String sUrl, String encode, String cookie, String host, String referer) {
HttpURLConnection connection = null;
InputStream in = null;
StringBuffer strResult = new StringBuffer();
try {
URL url = new URL(sUrl);
connection = (HttpURL... | public void writeToFtp(String login, String password, String address, String directory, String filename) {
String newline = System.getProperty("line.separator");
try {
URL url = new URL("ftp://" + login + ":" + password + "@ftp." + address + directory + filename + ".html" + ";type=i");
... | false |
5,450 | 21,585,794 | 6,614,947 | 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 String getPageSource(String url) throws ClientProtocolException, IOException {
HttpClient client = new DefaultHttpClient();
HttpGet request = new HttpGet(url);
HttpResponse response = client.execute(request);
InputStream in = response.getEntity().getContent();
B... | false |
5,451 | 22,467,291 | 15,480,455 | public void testExecute() throws Exception {
LocalWorker worker = new JTidyWorker();
URL url = new URL("http://www.nature.com/index.html");
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String str;
StringBuffer sb = new StringBuffer();
... | public static void TestDBStore() throws PDException, Exception {
StoreDDBB StDB = new StoreDDBB("jdbc:derby://localhost:1527/Prodoc", "Prodoc", "Prodoc", "org.apache.derby.jdbc.ClientDriver;STBLOB");
System.out.println("Driver[" + StDB.getDriver() + "] Tabla [" + StDB.getTable() + "]");
StD... | false |
5,452 | 3,772,396 | 2,617,135 | 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 String generate(String documentSelector) {
if (documentSelector == null) {
return null;
}
String date = Long.toString(System.currentTimeMillis());
try {
MessageDigest md = MessageDigest.getInstance(HASH_ALGORITHM);
md.update(documentS... | true |
5,453 | 22,717,352 | 22,900,247 | public void add(AddInterceptorChain chain, Entry entry, LDAPConstraints constraints) throws LDAPException {
Connection con = (Connection) chain.getRequest().get(JdbcInsert.MYVD_DB_CON + "LDAPBaseServer");
if (con == null) {
throw new LDAPException("Operations Error", LDAPException.OPERAT... | public static void copyDirectory(File sourceDirectory, File targetDirectory) throws IOException {
File[] sourceFiles = sourceDirectory.listFiles(FILE_FILTER);
File[] sourceDirectories = sourceDirectory.listFiles(DIRECTORY_FILTER);
targetDirectory.mkdirs();
if (sourceFiles != null && ... | false |
5,454 | 10,303,667 | 4,208,869 | @Override
public void copy(final String fileName) throws FileIOException {
final long savedCurrentPositionInFile = currentPositionInFile;
if (opened) {
closeImpl();
}
final FileInputStream fis;
try {
fis = new FileInputStream(file);
} catch... | public static void putNextJarEntry(JarOutputStream modelStream, String name, File file) throws IOException {
JarEntry entry = new JarEntry(name);
entry.setSize(file.length());
modelStream.putNextEntry(entry);
InputStream fileStream = new BufferedInputStream(new FileInputStream(file))... | true |
5,455 | 175,778 | 22,691,375 | public void sendShape(String s) {
try {
URLConnection uc = new URL(url + "&add=" + s).openConnection();
InputStream in = uc.getInputStream();
int b;
while ((b = in.read()) != -1) {
}
in.close();
} catch (IOException ex) {
... | @Override
protected String getRawPage(String url) throws IOException {
HttpClient httpClient = new HttpClient();
String proxyHost = config.getString("proxy.host"), proxyPortString = config.getString("proxy.port");
if (proxyHost != null && proxyPortString != null) {
int proxyP... | false |
5,456 | 17,513,478 | 7,005,223 | public void create(File target) {
if ("dir".equals(type)) {
File dir = new File(target, name);
dir.mkdirs();
for (Resource c : children) {
c.create(dir);
}
} else if ("package".equals(type)) {
String[] dirs = name.split("\\.... | public void checkFilesAndCopyValid(String filename) {
downloadResults();
loadResults();
File tmpFolderF = new File(tmpFolder);
deleteFileFromTMPFolder(tmpFolderF);
ZipReader zr = new ZipReader();
zr.UnzipFile(filename);
try {
LogManager.getInstance... | true |
5,457 | 10,540,679 | 6,184,983 | private static void downloadFile(String downloadFileName) throws Exception {
URL getFileUrl = new URL("http://www.tegsoft.com/Tobe/getFile" + "?tegsoftFileName=" + downloadFileName);
URLConnection getFileUrlConnection = getFileUrl.openConnection();
InputStream is = getFileUrlConnection.getIn... | @Override
public boolean copyFile(String srcRootPath, String srcDir, String srcFileName, String destRootPath, String destDir, String destFileName) {
File srcPath = new File(srcRootPath + separator() + Database.getDomainName() + separator() + srcDir);
if (!srcPath.exists()) {
try {
... | true |
5,458 | 14,803,892 | 6,492,265 | public File getURL(URL url) throws IOException {
URLConnection conn = null;
File tempFile = null;
Logger l = Logger.instance();
String className = getClass().getName();
l.log(Logger.DEBUG, loggerPrefix, className + ".getURL", "GET URL " + url.toString());
try {
... | 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... | false |
5,459 | 8,335,943 | 8,043,217 | public static byte[] sendRequestV2(String url, String content, Map<String, String> headers, String method, String contenttype) {
byte[] result = null;
try {
HttpURLConnection httpConn = (HttpURLConnection) new URL(url).openConnection();
httpConn.setUseCaches(false);
... | public static Image getImage(URL url) throws IOException {
InputStream is = null;
try {
is = url.openStream();
Image img = getImage(is);
img.setUrl(url);
return img;
} finally {
if (is != null) {
is.close();
... | false |
5,460 | 23,597,499 | 4,923,514 | private File uploadFile(InputStream inputStream, File file) {
FileOutputStream fileOutputStream = null;
try {
File dir = file.getParentFile();
if (!dir.exists()) {
dir.mkdirs();
}
FileUtils.touch(file);
fileOutputStream = ne... | public static void main(String[] args) {
if (args.length != 3) {
System.out.println("Usage: HexStrToBin enc/dec <infileName> <outfilename>");
System.exit(1);
}
try {
ByteArrayOutputStream os = new ByteArrayOutputStream();
InputStream in = new F... | true |
5,461 | 4,223,265 | 8,309,142 | public static String getMD5(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 boolean check(String password) throws UnsupportedEncodingException, NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(username.getBytes("ISO-8859-1"));
md.update((byte) ':');
md.update(realm.getBytes("ISO-8859-1"));
md.update((by... | true |
5,462 | 22,031,237 | 19,053,519 | @Override
public ReturnValue do_run() {
int bufLen = 500 * 1024;
ReturnValue ret = new ReturnValue();
ret.setExitStatus(ReturnValue.SUCCESS);
File output = null;
if (((String) options.valueOf("input-file")).startsWith("s3://")) {
Pattern p = Pattern.compile("s... | protected String getManualDownloadURL() {
if (_newestVersionString.indexOf("weekly") > 0) {
return "http://www.cs.rice.edu/~javaplt/drjavarice/weekly/";
}
final String DRJAVA_FILES_PAGE = "http://sourceforge.net/project/showfiles.php?group_id=44253";
final String LINK_PRE... | false |
5,463 | 18,731,110 | 22,919,520 | public static boolean decodeFileToFile(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.... | public static void copyFile(String sourceFilePath, String destFilePath) throws IOException {
FileChannel in = null;
FileChannel out = null;
try {
in = new FileInputStream(sourceFilePath).getChannel();
out = new FileOutputStream(destFilePath).getChannel();
... | true |
5,464 | 21,319,238 | 3,046,300 | FileCacheInputStreamFountain(FileCacheInputStreamFountainFactory factory, InputStream in) throws IOException {
file = factory.createFile();
OutputStream out = new FileOutputStream(file);
IOUtils.copy(in, out);
in.close();
out.close();
}
| private void copyFileToPhotoFolder(File photo, String personId) {
try {
FileChannel in = new FileInputStream(photo).getChannel();
File dirServer = new File(Constants.PHOTO_DIR);
if (!dirServer.exists()) {
dirServer.mkdirs();
}
File ... | true |
5,465 | 9,219,798 | 2,664,954 | public static void decryptFile(String infile, String outfile, String keyFile) throws Exception {
javax.crypto.Cipher cipher = javax.crypto.Cipher.getInstance("DES/ECB/PKCS5Padding");
cipher.init(javax.crypto.Cipher.DECRYPT_MODE, getKey());
java.io.FileInputStream in = new java.io.FileInputSt... | public void run() {
try {
status = UploadStatus.INITIALISING;
if (megaUploadAccount.loginsuccessful) {
login = true;
host = megaUploadAccount.username + " | MegaUpload.com";
} else {
login = false;
host = "Me... | false |
5,466 | 6,847,452 | 2,911,006 | public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
try {
String act = request.getParameter("act");
if (null == act) {
} else if ("down".equalsIgnoreCase(act)) {
String vest = request.getParam... | protected String encrypt(String text) {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA");
md.update(text.getBytes("UTF-8"));
byte raw[] = md.digest();
String hash = (new BASE64Encoder()).encode(raw);
return hash;
... | false |
5,467 | 3,220,986 | 22,382,181 | public static String calculateHash(String password) {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA-1");
md.reset();
} catch (NoSuchAlgorithmException ex) {
ex.printStackTrace();
}
md.update(password.getBytes());
... | public boolean copy(File src, File dest, byte[] b) {
if (src.isDirectory()) {
String[] ss = src.list();
for (int i = 0; i < ss.length; i++) if (!copy(new File(src, ss[i]), new File(dest, ss[i]), b)) return false;
return true;
}
delete(dest);
dest.g... | false |
5,468 | 2,217,508 | 22,271,847 | public static void copyFile(final File sourceFile, final File destFile) throws IOException {
if (destFile.getParentFile() != null && !destFile.getParentFile().mkdirs()) {
LOG.error("GeneralHelper.copyFile(): Cannot create parent directories from " + destFile);
}
FileInputStream f... | public static String encryptPassword(String password) {
try {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(password.getBytes());
byte[] hash = md.digest();
int hashLength = hash.length;
StringBuffer hashStringBuf = new StringBuffe... | false |
5,469 | 431,827 | 18,972,686 | 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 jsFunction_addFile(ScriptableFile infile) throws IOException {
if (!infile.jsFunction_exists()) throw new IllegalArgumentException("Cannot add a file that doesn't exists to an archive");
ZipArchiveEntry entry = new ZipArchiveEntry(infile.getName());
entry.setSize(infile.jsFunctio... | true |
5,470 | 15,536,899 | 8,052,478 | private String generateCode(String seed) {
try {
Security.addProvider(new FNVProvider());
MessageDigest digest = MessageDigest.getInstance("FNV-1a");
digest.update((seed + UUID.randomUUID().toString()).getBytes());
byte[] hash1 = digest.digest();
S... | private static void execute(String fileName) throws IOException, SQLException {
InputStream input = DatabaseConstants.class.getResourceAsStream(fileName);
StringWriter writer = new StringWriter();
IOUtils.copy(input, writer);
String sql = writer.toString();
Statement statemen... | false |
5,471 | 7,872,668 | 13,216,961 | private static boolean computeCustomerAverages(String completePath, String CustomerAveragesOutputFileName, String CustIndexFileName) {
try {
File inputFile = new File(completePath + fSep + "SmartGRAPE" + fSep + CustIndexFileName);
FileChannel inC = new FileInputStream(inputFile).getC... | public void actionPerformed(ActionEvent ev) {
if (fileChooser == null) {
fileChooser = new JFileChooser();
ExtensionFileFilter fileFilter = new ExtensionFileFilter("Device profile (*.jar, *.zip)");
fileFilter.addExtension("jar");
fileFi... | true |
5,472 | 3,076,854 | 19,603,031 | public static byte[] 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();
... | public static String convetToSignature(Map<String, String> keyVal, String apiSecret) {
if (keyVal == null || apiSecret == null || keyVal.size() <= 0 || apiSecret.trim().equals("")) {
throw new IllegalArgumentException("keyVal or api secret is not valid. Please Check it again.");
}
... | true |
5,473 | 19,267,854 | 4,928,350 | public static void insertTableData(Connection dest, TableMetaData tableMetaData) throws Exception {
PreparedStatement ps = null;
try {
dest.setAutoCommit(false);
String sql = "INSERT INTO " + tableMetaData.getSchema() + "." + tableMetaData.getTableName() + " (";
f... | 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());
... | false |
5,474 | 21,354,223 | 10,816,494 | public String kodetu(String testusoila) {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA");
md.update(testusoila.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
new MezuLeiho("Ez da zifraketa algoritmoa aurkitu", "Ados", "Zif... | @Override
public void sendData(String serverUrl, String fileName, String type, InputStream is) throws IOException {
ClientSession clientSession = null;
try {
if (logger.isDebugEnabled()) {
logger.debug("Connecting to " + serverUrl);
}
clientSes... | false |
5,475 | 1,516,551 | 22,998,999 | public static HttpURLConnection getHttpConn(String urlStr, String Method) throws IOException {
URL url = null;
HttpURLConnection connection = null;
url = new URL(urlStr);
connection = (HttpURLConnection) url.openConnection();
connection.setDoOutput(true);
connection.s... | public static void concatFiles(List<File> sourceFiles, File destFile) throws IOException {
FileOutputStream outFile = new FileOutputStream(destFile);
FileChannel outChannel = outFile.getChannel();
for (File f : sourceFiles) {
FileInputStream fis = new FileInputStream(f);
... | false |
5,476 | 15,364,153 | 13,247,325 | private void storeConfigurationPropertiesFile(java.net.URL url, String comp) {
java.util.Properties p;
try {
p = new java.util.Properties();
p.load(url.openStream());
} catch (java.io.IOException ie) {
System.err.println("error opening: " + url.getPath() +... | @Override
public String getPath() {
InputStream in = null;
OutputStream out = null;
File file = null;
try {
file = File.createTempFile("java-storage_" + RandomStringUtils.randomAlphanumeric(32), ".tmp");
file.deleteOnExit();
out = new FileOutpu... | false |
5,477 | 15,760,850 | 20,491,150 | public static void main(String[] args) {
File container = new File(ArchiveFeature.class.getProtectionDomain().getCodeSource().getLocation().toURI());
if (container == null) {
throw new RuntimeException("this use-case isn't being invoked from the executable jar");
}
JarFil... | private void retrieveClasses(URL url, Map<String, T> cmds) {
try {
String resource = URLDecoder.decode(url.getPath(), "UTF-8");
File directory = new File(resource);
if (directory.exists()) {
String[] files = directory.list();
for (String fi... | false |
5,478 | 9,830,269 | 861,011 | 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... | 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... | true |
5,479 | 3,516,106 | 12,488,277 | private void getRandomGUID(boolean secure) {
MessageDigest md5 = null;
StringBuffer sbValueBeforeMD5 = new StringBuffer();
try {
md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
System.out.println("Error: " + e);
}
... | public void loginMD5() throws Exception {
GetMethod get = new GetMethod("http://login.yahoo.com/config/login?.src=www&.done=http://www.yahoo.com");
get.setRequestHeader("user-agent", "Mozilla/5.0 (Macintosh; U; PPC MacOS X; en-us) AppleWebKit/124 (KHTML, like Gecko) Safari/125.1");
client.ex... | true |
5,480 | 2,440,033 | 7,283,902 | public Blowfish(String password) {
MessageDigest digest = null;
try {
digest = MessageDigest.getInstance("SHA1");
digest.update(password.getBytes());
} catch (Exception e) {
System.out.println(e);
}
m_bfish = new BlowfishCBC(digest.digest()... | public static String hashString(String pwd) {
StringBuffer hex = new StringBuffer();
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(pwd.getBytes());
byte[] d = md.digest();
String plaintxt;
for (int i = 0; i < d.length... | true |
5,481 | 21,644,149 | 21,182,830 | public void downloadQFromMinibix(int ticketNo) {
String minibixDomain = Preferences.userRoot().node("Spectatus").get("MBAddr", "http://mathassess.caret.cam.ac.uk");
String minibixPort = Preferences.userRoot().node("Spectatus").get("MBPort", "80");
String url = minibixDomain + ":" + minibixPo... | public void buildCache() {
XMLCacheBuilder cacheBuilder = CompositePageUtil.getCacheBuilder();
String postFix = "";
if (cacheBuilder.getPostFix() != null && !cacheBuilder.getPostFix().equals("")) {
postFix = "." + cacheBuilder.getPostFix();
}
String basePath = cac... | false |
5,482 | 4,886,971 | 6,270,868 | private static void copyFile(String srFile, String dtFile) {
try {
File f1 = new File(srFile);
File f2 = new File(dtFile);
InputStream in = new FileInputStream(f1);
OutputStream out = new FileOutputStream(f2);
byte[] buf = new byte[1024];
... | public static String shaEncrypt(final String txt) {
String enTxt = txt;
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
logger.error("Error:", e);
}
if (null != md) {
by... | false |
5,483 | 11,403,723 | 21,028,032 | public static void copy(final File src, final File dest) throws IOException {
OutputStream stream = new FileOutputStream(dest);
FileInputStream fis = new FileInputStream(src);
byte[] buffer = new byte[16384];
while (fis.available() != 0) {
int read = fis.read(buffer);
... | public void convert(File file, String fromEncoding, String toEncoding) throws IOException {
InputStream in = new FileInputStream(file);
StringWriter cache = new StringWriter();
Reader reader = new InputStreamReader(in, fromEncoding);
char[] buffer = new char[128];
int read;
... | true |
5,484 | 14,430,650 | 2,517,852 | 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())... | public String contentType() {
if (_contentType != null) {
return (String) _contentType;
}
String uti = null;
URL url = url();
System.out.println("OKIOSIDManagedObject.contentType(): url = " + url + "\n");
if (url != null) {
String contentType =... | false |
5,485 | 11,020,815 | 6,693,221 | public static byte[] getbytes(String host, int port, String cmd) {
String result = "GetHtmlFromServer no answer";
String tmp = "";
result = "";
try {
tmp = "http://" + host + ":" + port + "/" + cmd;
URL url = new URL(tmp);
if (1 == 2) {
... | public void dumpDB(String in, String out) {
try {
FileChannel inChannel = new FileInputStream(in).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
inChannel.transferTo(0, inChannel.size(), outChannel);
inChannel.close();
... | false |
5,486 | 210,587 | 2,498,760 | 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 Main(String[] args) {
boolean encrypt = false;
if (args[0].compareTo("-e") == 0) {
encrypt = true;
} else if (args[0].compareTo("-d") == 0) {
encrypt = false;
} else {
System.out.println("first argument is invalid");
System.exit(... | true |
5,487 | 841,792 | 13,868,519 | public static void doVersionCheck(View view) {
view.showWaitCursor();
try {
URL url = new URL(jEdit.getProperty("version-check.url"));
InputStream in = url.openStream();
BufferedReader bin = new BufferedReader(new InputStreamReader(in));
String line;
... | public static void addClasses(URL url) {
BufferedReader reader = null;
String line;
ClassLoader cl = Thread.currentThread().getContextClassLoader();
try {
reader = new BufferedReader(new InputStreamReader(url.openStream()));
while ((line = reader.readLine()) !... | true |
5,488 | 21,186,037 | 716,032 | public Project createProject(int testbedID, String name, String description) throws AdaptationException {
Project project = null;
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
try {
String query = "INSERT INTO Projects(testb... | public void getZipFiles(String filename) {
try {
String destinationname = "c:\\mods\\peu\\";
byte[] buf = new byte[1024];
ZipInputStream zipinputstream = null;
ZipEntry zipentry;
zipinputstream = new ZipInputStream(new FileInputStream(filename));
... | false |
5,489 | 12,768,281 | 3,026,764 | 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);
... | public MoteDeploymentConfiguration addMoteDeploymentConfiguration(int projectDepConfID, int moteID, int programID, int radioPowerLevel) throws AdaptationException {
MoteDeploymentConfiguration mdc = null;
Connection connection = null;
Statement statement = null;
ResultSet resultSet =... | true |
5,490 | 14,488,295 | 17,585,720 | public static synchronized void loadConfig(String configFile) {
if (properties != null) {
return;
}
URL url = null;
InputStream is = null;
try {
String configProperty = null;
try {
configProperty = System.getProperty("dspace... | public static void copyFile(File in, File out) throws IOException {
FileChannel inChannel = new FileInputStream(in).getChannel();
FileChannel outChannel = new FileOutputStream(out).getChannel();
try {
int maxCount = (64 * 1024 * 1024) - (32 * 1024);
long size = inChan... | false |
5,491 | 1,655,162 | 4,982,455 | public boolean updatenum(int num, String pid) {
boolean flag = false;
Connection conn = null;
PreparedStatement pm = null;
try {
conn = Pool.getConnection();
conn.setAutoCommit(false);
pm = conn.prepareStatement("update addwuliao set innum=? where ... | static final void saveStatus(JWAIMStatus status, DBConnector connector) throws IOException {
Connection con = null;
PreparedStatement ps = null;
Statement st = null;
try {
con = connector.getDB();
con.setAutoCommit(false);
st = con.createStatement(... | true |
5,492 | 22,487,030 | 3,469,470 | public static synchronized String encrypt(String plaintextPassword) throws Exception {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA");
} catch (NoSuchAlgorithmException e) {
throw new Exception(e);
}
try {
md.update(pl... | public static String encrypt(String text) {
char[] toEncrypt = text.toCharArray();
StringBuffer hexString = new StringBuffer();
try {
MessageDigest dig = MessageDigest.getInstance("MD5");
dig.reset();
String pw = "";
for (int i = 0; i < toEncry... | true |
5,493 | 7,898,667 | 9,632,240 | public LogoutHandler(String username, String token) {
try {
URL url = new URL("http://eiffel.itba.edu.ar/hci/service/Security.groovy?method=LogOut&username=" + username + "&authentication_token=" + token);
URLConnection urlc = url.openConnection();
urlc.setDoOutput(false)... | private final boolean copy_to_file_nio(File src, File dst) throws IOException {
FileChannel srcChannel = null, dstChannel = null;
try {
srcChannel = new FileInputStream(src).getChannel();
dstChannel = new FileOutputStream(dst).getChannel();
{
int s... | false |
5,494 | 15,385,607 | 7,398,604 | public boolean addFavBoard(BoardObject board) throws NetworkException, ContentException {
String url = HttpConfig.bbsURL() + HttpConfig.BBS_FAV_ADD + board.getId();
HttpClient client = HttpConfig.newInstance();
HttpGet get = new HttpGet(url);
try {
HttpResponse response =... | @Override
public Collection<IAuthor> doImport() throws Exception {
progress.initialize(2, "Ściągam autorów amerykańskich");
String url = "http://pl.wikipedia.org/wiki/Kategoria:Ameryka%C5%84scy_autorzy_fantastyki";
UrlResource resource = new UrlResource(url);
InputStream urlInput... | false |
5,495 | 170,006 | 12,568,442 | void bubbleSort(int[] a) {
int i = 0;
int j = a.length - 1;
int aux = 0;
int stop = 0;
while (stop == 0) {
stop = 1;
i = 0;
while (i < j) {
if (a[i] > a[i + 1]) {
aux = a[i];
a[i] = a[... | public static String MD5(String text) {
byte[] md5hash = new byte[32];
try {
MessageDigest md;
md = MessageDigest.getInstance("MD5");
md.update(text.getBytes("iso-8859-1"), 0, text.length());
md5hash = md.digest();
} catch (Exception e) {
... | false |
5,496 | 3,743,400 | 5,537,138 | private static byte[] calcMd5(String pass) {
try {
MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
digest.update(pass.getBytes(), 0, pass.length());
byte[] hash = digest.digest();
return hash;
} catch (NoSuchAlgorithmException e)... | public static String getDigest(String seed, String code) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(seed.getBytes("UTF-8"));
byte[] passwordMD5Byte = md.digest(code.getBytes("UTF-8"));
StringBuffer sb = new StringBuffer();
... | true |
5,497 | 11,854,456 | 21,898,978 | public static int copy(File src, int amount, File dst) {
final int BUFFER_SIZE = 1024;
int amountToRead = amount;
boolean ok = true;
InputStream in = null;
OutputStream out = null;
try {
in = new BufferedInputStream(new FileInputStream(src));
o... | public static String SHA1(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
if (text == null || text.length() < 1) {
return null;
}
MessageDigest md = MessageDigest.getInstance(TYPE_SHA);
md.update(text.getBytes(ENCODE), 0, text.length());
... | false |
5,498 | 9,136,261 | 9,840,907 | public void copyFile(String source_name, String dest_name) throws IOException {
File source_file = new File(source_name);
File destination_file = new File(dest_name);
Reader source = null;
Writer destination = null;
char[] buffer;
int bytes_read;
try {
... | public static final void copyFile(File source, File destination) throws IOException {
FileChannel sourceChannel = new FileInputStream(source).getChannel();
FileChannel targetChannel = new FileOutputStream(destination).getChannel();
sourceChannel.transferTo(0, sourceChannel.size(), targetChan... | true |
5,499 | 16,797,428 | 1,477,292 | private void copy(File sourceFile, File destinationFile) {
try {
FileChannel in = new FileInputStream(sourceFile).getChannel();
FileChannel out = new FileOutputStream(destinationFile).getChannel();
try {
in.transferTo(0, in.size(), out);
in... | public void testCreate() throws Exception {
File f = File.createTempFile("DiskCacheItemTest", "tmp");
f.deleteOnExit();
try {
DiskCacheItem i = new DiskCacheItem(f);
i.setLastModified(200005L);
i.setTranslationCount(11);
i.setEncoding("GB2312")... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.