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,100 | 17,551,920 | 22,769,774 | @Override
public void execute() throws ProcessorExecutionException {
try {
if (getSource().getPaths() == null || getSource().getPaths().size() == 0 || getDestination().getPaths() == null || getDestination().getPaths().size() == 0) {
throw new ProcessorExecutionException("No i... | 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... | true |
4,101 | 1,508,164 | 13,794,582 | public boolean delMail(MailObject mail) throws NetworkException, ContentException {
HttpClient client = HttpConfig.newInstance();
HttpGet get = new HttpGet(HttpConfig.bbsURL() + HttpConfig.BBS_MAIL_DEL + mail.getId());
try {
HttpResponse response = client.execute(get);
... | public Source get_source(String pageURL, Boolean checkInBase) {
URL url;
URLConnection conn;
Reader inReader;
Source source = null;
String LastModified = "";
Boolean updateData = false;
try {
url = new URL(pageURL);
conn = url.openConne... | false |
4,102 | 8,931,241 | 14,389,765 | public static void copy(File from, File to, CopyMode mode) throws IOException {
if (!from.exists()) {
IllegalArgumentException e = new IllegalArgumentException("Source doesn't exist: " + from.getCanonicalFile());
log.throwing("IOUtils", "copy", e);
throw e;
}
... | private void loadProperties() {
if (properties == null) {
properties = new Properties();
try {
URL url = getClass().getResource(propsFile);
properties.load(url.openStream());
} catch (IOException ioe) {
ioe.printStackTrace()... | false |
4,103 | 15,405,846 | 8,296,360 | public DataSet guessAtUnknowns(String filename) {
TasselFileType guess = TasselFileType.Sequence;
DataSet tds = null;
try {
BufferedReader br = null;
if (filename.startsWith("http")) {
URL url = new URL(filename);
br = new BufferedReade... | public static void copiaAnexos(String from, String to, AnexoTO[] anexoTO) {
FileChannel in = null, out = null;
for (int i = 0; i < anexoTO.length; i++) {
try {
in = new FileInputStream(new File((uploadDiretorio.concat(from)).concat(File.separator + anexoTO[i].getNome())))... | false |
4,104 | 242,983 | 8,335,460 | public void fetchFile(String ID) {
String url = "http://www.nal.usda.gov/cgi-bin/agricola-ind?bib=" + ID + "&conf=010000++++++++++++++&screen=MA";
System.out.println(url);
try {
PrintWriter pw = new PrintWriter(new FileWriter("MARC" + ID + ".txt"));
if (!id.contains("... | public static String encrypt(String password, String algorithm, byte[] salt) {
StringBuffer buffer = new StringBuffer();
MessageDigest digest = null;
int size = 0;
if ("CRYPT".equalsIgnoreCase(algorithm)) {
throw new InternalError("Not implemented");
} else if ("S... | false |
4,105 | 21,090,886 | 1,152,136 | public static String calculateHA2(String uri) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(getBytes("GET", ISO_8859_1));
md.update((byte) ':');
md.update(getBytes(uri, ISO_8859_1));
return toHexString(md.digest());
... | @SuppressWarnings("unchecked")
public ArrayList<GmailContact> getAllContacts() throws GmailException {
String query = properties.getString("export_page");
query = query.replace("[RANDOM_INT]", "" + random.nextInt());
int statusCode = -1;
GetMethod get = new GetMethod(query);
... | true |
4,106 | 21,302,551 | 11,896,430 | public static Document convertHtmlToXml(final InputStream htmlInputStream, final String classpathXsltResource, final String encoding) {
Parser p = new Parser();
javax.xml.parsers.DocumentBuilder db;
try {
db = javax.xml.parsers.DocumentBuilderFactory.newInstance().newDocumentBuil... | protected InputStream createIconType(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
JavaliController.debug(JavaliController.LG_VERBOSE, "Creating iconType");
String cHash = PRM_TYPE + "=" + TP_ICON;
String iconName = req.getParameter("iconName");
... | true |
4,107 | 430,406 | 17,750,515 | 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 SukuData updatePerson(String usertext, SukuData req) {
String insPers;
String userid = Utils.toUsAscii(usertext);
if (userid != null && userid.length() > 16) {
userid = userid.substring(0, 16);
}
StringBuilder sb = new StringBuilder();
sb.append("in... | true |
4,108 | 2,329,317 | 21,493,548 | public ArrayList loadIndexes() {
JSONObject job = new JSONObject();
ArrayList al = new ArrayList();
try {
String req = job.put("OperationId", "1").toString();
InputStream is = null;
String result = "";
JSONObject jArray = null;
try ... | private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
URL url = new URL(upgradeURL);
InputStream in = url.openStream();
BufferedInputStream buffIn = new BufferedInputStream(in);
FileOutputStream out = new FileOutputStream("");
... | false |
4,109 | 9,096,612 | 17,261,985 | public void include(String href) throws ProteuException {
try {
if (href.toLowerCase().startsWith("http://")) {
java.net.URLConnection urlConn = (new java.net.URL(href)).openConnection();
Download.sendInputStream(this, urlConn.getInputStream());
} else... | public int doEndTag() throws JspException {
HttpSession session = pageContext.getSession();
try {
IntactUserI user = (IntactUserI) session.getAttribute(Constants.USER_KEY);
String urlStr = user.getSourceURL();
if (urlStr == null) {
return EVAL_PAGE... | false |
4,110 | 5,271,062 | 13,979,533 | private void copyThemeProviderClass() throws Exception {
InputStream is = getClass().getResourceAsStream("/zkthemer/ThemeProvider.class");
if (is == null) throw new RuntimeException("Cannot find ThemeProvider.class");
File outFile = new File(theme.getJarRootFile(), "zkthemer/ThemeProvider.cl... | public Resource get(URL serviceUrl, String resourceId) throws Exception {
Resource resource = new Resource();
String openurl = serviceUrl.toString() + "?url_ver=Z39.88-2004" + "&rft_id=" + URLEncoder.encode(resourceId, "UTF-8") + "&svc_id=" + SVCID_ADORE4;
log.debug("OpenURL Request: " + ope... | false |
4,111 | 4,781,643 | 18,899,334 | public static void loadConfig(URL urlFile) throws CacheException {
Document document;
try {
document = Utilities.getDocument(urlFile.openStream());
} catch (IOException e) {
throw new CacheException("Could not open '" + urlFile.getFile() + "'", e);
} catch (JA... | public static void parseSinaGGTJ(ArrayList<String> dataSource, final ArrayList<SinaGGTJBean> sinaGGTJBeanList) throws IOReactorException, InterruptedException {
HttpAsyncClient httpclient = new DefaultHttpAsyncClient();
httpclient.start();
if (dataSource != null && dataSource.size() > 0) {
... | false |
4,112 | 20,228,526 | 18,054,947 | public static File downloadURL(URL url, File dir, String sfilename) {
MerlotDebug.msg("Downloading URL: " + url);
String filename = url.getFile();
if (filename.indexOf('/') >= 0) {
filename = filename.substring(filename.lastIndexOf('/') + 1);
}
File cache = new Fi... | 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 {
... | false |
4,113 | 843,811 | 16,993,715 | public static void main(String[] args) throws Exception {
String codecClassname = args[0];
Class<?> codecClass = Class.forName(codecClassname);
Configuration conf = new Configuration();
CompressionCodec codec = (CompressionCodec) ReflectionUtils.newInstance(codecClass, conf);
... | public static boolean copyFile(String fromfile, String tofile) {
File from = new File(fromfile);
File to = new File(tofile);
if (!from.exists()) return false;
if (to.exists()) {
log.error(tofile + "exists already");
return false;
}
BufferedInpu... | true |
4,114 | 13,104,737 | 18,366,943 | private void initialize() {
StringBuffer license = new StringBuffer();
URL url;
InputStreamReader in;
BufferedReader reader;
String str;
JTextArea textArea;
JButton button;
GridBagConstraints c;
setTitle("Mibble License");
setSize(600, ... | 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,115 | 9,713,536 | 20,761,702 | @SuppressWarnings("unchecked")
private void doService(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
final String url = request.getRequestURL().toString();
if (url.endsWith("/favicon.ico")) {
response.setStatus(HttpServlet... | private File newFile(File oldFile) throws IOException {
int counter = 0;
File nFile = new File(this.stateDirProvider.get() + File.separator + oldFile.getName());
while (nFile.exists()) {
nFile = new File(this.stateDirProvider.get() + File.separator + oldFile.getName() + "_" + cou... | true |
4,116 | 555,928 | 7,901,588 | private static File copyFileTo(File file, File directory) throws IOException {
File newFile = new File(directory, file.getName());
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(file);
fos = new FileOutputStream(newFil... | public static long removePropertyInOpenXMLDocument(String ext, InputStream in, OutputStreamProvider outProvider, String propriete) {
in = new BufferedInputStream(in);
try {
File tempPptx = null;
POIXMLDocument doc;
if (ext.toLowerCase().equals("docx")) {
... | true |
4,117 | 12,937,087 | 19,603,031 | public ChatClient registerPlayer(int playerId, String playerLogin) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.reset();
md.update(playerLogin.getBytes("UTF-8"), 0, playerLogin.length());
byte[] accountTok... | 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 |
4,118 | 10,453,631 | 20,444,225 | public synchronized String encrypt(String plaintext) {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA");
md.update(plaintext.getBytes("UTF-8"));
} catch (NoSuchAlgorithmException e) {
log().error("failed to encrypt the password.", e);
... | private byte[] getMergedContent(List names, ServletContext servletContext) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
for (Iterator iterator = names.iterator(); iterator.hasNext(); ) {
String path = (String) iterator.next();
if (!path.start... | false |
4,119 | 19,144,041 | 17,347,450 | public ChatClient registerPlayer(int playerId, String playerLogin) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md = MessageDigest.getInstance("SHA-256");
md.reset();
md.update(playerLogin.getBytes("UTF-8"), 0, playerLogin.length());
byte[] accountTok... | public static byte[] MD5(String... strings) {
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
digest.reset();
for (String string : strings) {
digest.update(string.getBytes("UTF-8"));
}
return digest.digest();
... | true |
4,120 | 19,474,501 | 20,474,021 | 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 static byte[] createAuthenticator(ByteBuffer data, String secret) {
assert data.isDirect() == false : "must not a direct ByteBuffer";
int pos = data.position();
if (pos < RadiusPacket.MIN_PACKET_LENGTH) {
System.err.println("packet too small");
return null;
... | true |
4,121 | 597,134 | 1,544,996 | 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 static void transfer(FileInputStream fileInStream, FileOutputStream fileOutStream) throws IOException {
FileChannel fileInChannel = fileInStream.getChannel();
FileChannel fileOutChannel = fileOutStream.getChannel();
long fileInSize = fileInChannel.size();
try {
lon... | true |
4,122 | 17,334,846 | 20,880,642 | static String encodeEmailAsUserId(String email) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(email.toLowerCase().getBytes());
StringBuilder builder = new StringBuilder();
builder.append("1");
for (byte b : md5.digest()) ... | public static String getHash(String password, String salt) throws NoSuchAlgorithmException, UnsupportedEncodingException {
logger.debug("Entering getHash with password = " + password + "\n and salt = " + salt);
MessageDigest digest = MessageDigest.getInstance("SHA-512");
digest.reset();
... | true |
4,123 | 16,055,063 | 19,438,539 | public static EXISchema getEXISchema(String fileName, Class<?> cls, EXISchemaFactoryErrorHandler compilerErrorHandler) throws IOException, ClassNotFoundException, EXISchemaFactoryException {
EXISchemaFactory schemaCompiler = new EXISchemaFactory();
schemaCompiler.setCompilerErrorHandler(compilerErro... | public void run() throws Exception {
logger.debug("#run enter");
logger.debug("#run orderId = " + orderId);
ResultSet rs = null;
PreparedStatement ps = null;
try {
connection.setAutoCommit(false);
ps = connection.prepareStatement(SQL_SELECT_ORDER_LINE)... | false |
4,124 | 11,319,480 | 18,070,587 | 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.... | @Test
public void testWriteAndReadFirstLevel() throws Exception {
JCFSFileServer server = new JCFSFileServer(defaultTcpPort, defaultTcpAddress, defaultUdpPort, defaultUdpAddress, dir, 0, 0);
JCFS.configureDiscovery(defaultUdpAddress, defaultUdpPort);
try {
server.start();
... | true |
4,125 | 2,424,996 | 6,008,880 | protected void migrateOnDemand() {
try {
if (fso.fileExists(prefix + ".fat") && !fso.fileExists(prefix + EXTENSIONS[UBM_FILE])) {
RandomAccessFile ubm, meta, ctr, rbm;
InputStream inputStream;
OutputStream outputStream;
fso.renameFi... | protected void updateJava2ScriptProject(String prjFolder, String binRelative) {
try {
File cpFile = new File(prjFolder, ".classpath");
FileInputStream fis = new FileInputStream(cpFile);
String classpath = J2SLaunchingUtil.readAFile(fis);
if (classpath != null)... | true |
4,126 | 16,142,591 | 21,016,411 | public void initialize(IProgressMonitor monitor) throws JETException {
IProgressMonitor progressMonitor = monitor;
progressMonitor.beginTask("", 10);
progressMonitor.subTask(CodeGenPlugin.getPlugin().getString("_UI_GeneratingJETEmitterFor_message", new Object[] { getTemplateURI() }));
... | public File addFile(File file, String suffix) throws IOException {
if (file.exists() && file.isFile()) {
File nf = File.createTempFile(prefix, "." + suffix, workdir);
nf.delete();
if (!file.renameTo(nf)) {
IOUtils.copy(file, nf);
}
... | false |
4,127 | 6,451,560 | 16,338,011 | protected static String getBiopaxId(Reaction reaction) {
String id = null;
if (reaction.getId() > Reaction.NO_ID_ASSIGNED) {
id = reaction.getId().toString();
} else {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update... | protected byte[] getHashedID(String ID) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.reset();
md5.update(ID.getBytes());
byte[] digest = md5.digest();
byte[] bytes = new byte[WLDB_ID_SIZE];
for (int i = 0; i < bytes... | true |
4,128 | 14,638,788 | 10,654,982 | public static InputStream openURL(String url, ConnectData data) {
try {
URLConnection con = new URL(url).openConnection();
con.setConnectTimeout(TIMEOUT);
con.setReadTimeout(TIMEOUT);
con.setUseCaches(false);
con.setRequestProperty("Accept-Charset"... | public static String getEncryptedPassword(String password) throws PasswordException {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA");
md.update(password.getBytes("UTF-8"));
} catch (Exception e) {
throw new PasswordException(e);
... | false |
4,129 | 7,215,887 | 3,402,498 | public static String encrypt(String password, Long digestSeed) {
try {
MessageDigest algorithm = MessageDigest.getInstance("MD5");
algorithm.reset();
algorithm.update(password.getBytes("UTF-8"));
algorithm.update(digestSeed.toString().getBytes("UTF-8"));
... | private static void readFileEntry(Zip64File zip64File, FileEntry fileEntry, File destFolder) {
FileOutputStream fileOut;
File target = new File(destFolder, fileEntry.getName());
File targetsParent = target.getParentFile();
if (targetsParent != null) {
targetsParent.mkdirs... | false |
4,130 | 17,999,460 | 11,658,686 | public static long toFile(final DigitalObject object, final File file) {
try {
FileOutputStream fOut = new FileOutputStream(file);
long bytesCopied = IOUtils.copyLarge(object.getContent().getInputStream(), fOut);
fOut.close();
return bytesCopied;
} cat... | protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("application/zip");
response.setHeader("Content-Disposition", "inline; filename=c:/server1.zip");
try {
BufferedInputStream origi... | true |
4,131 | 22,743,765 | 8,350,427 | public void testCreateNewXMLFile() throws InvalidNodeTypeDefException, ParseException, Exception {
JCRNodeSource emptySource = loadTestSource();
assertEquals(false, emptySource.exists());
OutputStream sourceOut = emptySource.getOutputStream();
assertNotNull(sourceOut);
InputS... | public void handleEvent(Event event) {
if (fileDialog == null) {
fileDialog = new FileDialog(getShell(), SWT.OPEN);
fileDialog.setText("Open device profile file...");
fileDialog.setFilterNames(new String[] { "Device profile (*.jar)" });
... | true |
4,132 | 10,878,062 | 7,507,773 | public static void copy(File source, File dest) throws Exception {
FileInputStream in = new FileInputStream(source);
FileOutputStream out = new FileOutputStream(dest);
int c;
while ((c = in.read()) != -1) out.write(c);
in.close();
out.close();
}
| public boolean restore(File directory) {
log.debug("restore file from directory " + directory.getAbsolutePath());
try {
if (!directory.exists()) return false;
String[] operationFileNames = directory.list();
if (operationFileNames.length < 6) {
log.... | true |
4,133 | 2,066,343 | 2,459,317 | public static void copy(File source, File dest) throws FileNotFoundException, IOException {
FileInputStream input = new FileInputStream(source);
FileOutputStream output = new FileOutputStream(dest);
System.out.println("Copying " + source + " to " + dest);
IOUtils.copy(input, output);... | @Test
public void testStandardTee() throws Exception {
final byte[] test = "test".getBytes();
final InputStream source = new ByteArrayInputStream(test);
final ByteArrayOutputStream destination1 = new ByteArrayOutputStream();
final ByteArrayOutputStream destination2 = new ByteArra... | true |
4,134 | 4,385,640 | 12,247,514 | public static void copyFile(File sourceFile, File destFile) throws IOException {
if (!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
try {
source = new FileInputStream(sourceFile).getChannel(... | public static void main(String[] args) throws Exception {
if (args.length != 2) {
PrintUtil.prt("arguments: sourcefile, destfile");
System.exit(1);
}
FileChannel in = new FileInputStream(args[0]).getChannel(), out = new FileOutputStream(args[1]).getChannel();
... | true |
4,135 | 9,430,039 | 190,292 | private void CopyTo(File dest) throws IOException {
FileReader in = null;
FileWriter out = null;
int c;
try {
in = new FileReader(image);
out = new FileWriter(dest);
while ((c = in.read()) != -1) out.write(c);
} finally {
if (in... | private static void main(String[] args) {
try {
File f = new File("test.txt");
if (f.exists()) {
throw new IOException(f + " already exists. I don't want to overwrite it.");
}
StraightStreamReader in;
char[] cbuf = new char[0x1000]... | true |
4,136 | 20,870,396 | 10,113,882 | private 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 (IOExce... | private void createSaveServiceProps() throws MojoExecutionException {
saveServiceProps = new File(workDir, "saveservice.properties");
try {
FileWriter out = new FileWriter(saveServiceProps);
IOUtils.copy(Thread.currentThread().getContextClassLoader().getResourceAsStream("save... | true |
4,137 | 6,680,023 | 11,731,587 | public ResourceMigrator getCompletedResourceMigrator() {
return new ResourceMigrator() {
public void migrate(InputMetadata meta, InputStream inputStream, OutputCreator outputCreator) throws IOException, ResourceMigrationException {
... | public File createFileFromClasspathResource(String resourceUrl) throws IOException {
File fichierTest = File.createTempFile("xmlFieldTestFile", "");
FileOutputStream fos = new FileOutputStream(fichierTest);
InputStream is = XmlFieldDomSelectorTest.class.getResourceAsStream(resourceUrl);
... | true |
4,138 | 4,381,118 | 9,233,950 | private void loadFile(File file) throws Exception {
Edl edl = new Edl("file:///" + file.getAbsolutePath());
URL url = ExtractaHelper.retrieveUrl(edl.getUrlRetrievalDescriptor());
String sUrlString = url.toExternalForm();
if (sUrlString.startsWith("file:/") && (sUrlString.charAt(6) !=... | public static void copyFile(File src, File dest) throws IOException {
if (!src.exists()) throw new IOException("File not found '" + src.getAbsolutePath() + "'");
BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(dest));
BufferedInputStream in = new BufferedInputStream(... | false |
4,139 | 765,071 | 17,930,256 | public static void testString(String string, String expected) {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("MD5");
md.update(string.getBytes(), 0, string.length());
String result = toString(md.digest());
System.out.println(expected);... | private JButton getButtonImagen() {
if (buttonImagen == null) {
buttonImagen = new JButton();
buttonImagen.setText("Cargar Imagen");
buttonImagen.setIcon(new ImageIcon(getClass().getResource("/data/icons/view_sidetree.png")));
buttonImagen.addActionListener(ne... | false |
4,140 | 3,058,819 | 6,085,964 | public static void decryptFile(String input, String output, String pwd) throws Exception {
CipherInputStream in;
OutputStream out;
Cipher cipher;
SecretKey key;
byte[] byteBuffer;
cipher = Cipher.getInstance("DES");
key = new SecretKeySpec(pwd.getBytes(), "DES... | private static String readStreamToString(InputStream is, boolean passInVelocity, String tplName, Map<String, Object> templateVarsMap) throws IOException {
StringWriter sw = new StringWriter();
IOUtils.copy(is, sw, "UTF-8");
if (passInVelocity) {
return tpl.formatStr(sw.toString()... | true |
4,141 | 19,016,407 | 406,170 | public int print(String type, String url, String attrs) throws PrinterException {
try {
return print(type, (new URL(url)).openStream(), attrs);
} catch (Exception e) {
e.printStackTrace();
throw new PrinterException(e);
}
}
| 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 {
... | false |
4,142 | 19,392,393 | 11,504,871 | private void addIngredients(Recipe recipe, int id) throws Exception {
PreparedStatement pst = null;
try {
conn = getConnection();
pst = conn.prepareStatement("INSERT INTO ingredients (recipe_id, name, amount, measure_id, shop_flag) VALUES (?,?,?,?,?)");
Ingredient... | public static String encrypt(String password) throws NoSuchAlgorithmException {
java.security.MessageDigest d = null;
d = java.security.MessageDigest.getInstance("MD5");
d.reset();
d.update(password.getBytes());
byte[] cr = d.digest();
return getString(cr).toLowerCase... | false |
4,143 | 12,940,372 | 896,701 | private String encryptPassword(String password) {
String result = password;
if (password != null) {
try {
MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.reset();
md5.update(password.getBytes());
BigInteger hash = ... | 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... | false |
4,144 | 16,797,428 | 21,575,639 | 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... | protected byte[] readGZippedBytes(TupleInput in) {
final boolean is_compressed = in.readBoolean();
byte array[] = readBytes(in);
if (array == null) return null;
if (!is_compressed) {
return array;
}
try {
ByteArrayInputStream bais = new ByteArr... | true |
4,145 | 6,304,372 | 22,331,869 | public static String getUploadDeleteComboBox(String fromMode, String fromFolder, String action, String object, HttpSession session) {
FTPClient ftp = new FTPClient();
CofaxToolsUser user = (CofaxToolsUser) session.getAttribute("user");
StringBuffer links = new StringBuffer();
StringB... | protected void syncMessages(Message message) {
if (message.getEvent() == Event.CONNECT || message.getEvent() == Event.SYNC_DONE) return;
logger.info(String.format("remove stale replication messages: %s", message.toString()));
String className = "";
long classId = 0;
if (messa... | false |
4,146 | 20,063,872 | 9,068,281 | public void doInsertImage() {
logger.debug(">>> Inserting image...");
logger.debug(" fullFileName : #0", uploadedFileName);
String fileName = uploadedFileName.substring(uploadedFileName.lastIndexOf(File.separator) + 1);
logger.debug(" fileName : #0", fileName);
String newFile... | @Override
protected Class<?> findClass(String name) throws ClassNotFoundException {
String classFile = name.replace('.', '/') + ".class";
InputStream classInputStream = null;
for (JarFile java3DJar : this.java3DJars) {
JarEntry jarEntry = java3DJar.get... | false |
4,147 | 18,065,573 | 23,677,111 | private static String executeGet(String urlStr) {
StringBuffer result = new StringBuffer();
try {
Authentication.doIt();
URL url = new URL(urlStr);
System.out.println("Host: " + url.getHost());
BufferedReader in = new BufferedReader(new InputStreamRead... | public static String downloadWebpage1(String address) throws MalformedURLException, IOException {
URL url = new URL(address);
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
String page = "";
while((line = br.readLine()) != null) {
page += line + "\n";
}
b... | true |
4,148 | 11,499,032 | 1,725,721 | private void outputSignedOpenDocument(byte[] signatureData) throws IOException {
LOG.debug("output signed open document");
OutputStream signedOdfOutputStream = getSignedOpenDocumentOutputStream();
if (null == signedOdfOutputStream) {
throw new NullPointerException("signedOpenDocu... | public static int writeFile(URL url, File outFilename) {
InputStream input;
try {
input = url.openStream();
} catch (IOException e) {
e.printStackTrace();
return 0;
}
FileOutputStream outputStream;
try {
outputStream = n... | false |
4,149 | 18,046,716 | 12,687,609 | private List<String> getContainedFilePaths(URL url) throws Exception {
JarInputStream jis = new JarInputStream(url.openStream());
ZipEntry zentry = null;
ArrayList<String> fullNames = new ArrayList<String>();
while ((zentry = jis.getNextEntry()) != null) {
String name = z... | public boolean isWebServerAvaliable(String url) {
long inicial = new Date().getTime();
HttpURLConnection connection = null;
try {
URL urlBase = urlBase = new URL(url);
getLog().info("Verificando se WebServer esta no ar: " + urlBase.toString());
connection ... | false |
4,150 | 1,953,115 | 9,552,428 | protected int doWork() {
SAMFileReader reader = new SAMFileReader(IoUtil.openFileForReading(INPUT));
reader.getFileHeader().setSortOrder(SORT_ORDER);
SAMFileWriter writer = new SAMFileWriterFactory().makeSAMOrBAMWriter(reader.getFileHeader(), false, OUTPUT);
Iterator<SAMRecord> itera... | public static String stringOfUrl(String addr) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
System.out.println("test");
URL url = new URL(addr);
System.out.println("test2");
IOUtils.copy(url.openStream(), output);
return output.toStr... | true |
4,151 | 4,147,990 | 19,747,820 | public static void copyFile(File dst, File src, boolean append) throws FileNotFoundException, IOException {
dst.createNewFile();
FileChannel in = new FileInputStream(src).getChannel();
FileChannel out = new FileOutputStream(dst).getChannel();
long startAt = 0;
if (append) sta... | public String parse(String term) throws OntologyAdaptorException {
try {
String sUrl = getUrl(term);
if (sUrl.length() > 0) {
URL url = new URL(sUrl);
InputStream in = url.openStream();
StringBuilder sb = new StringBuilder();
... | false |
4,152 | 13,456,795 | 23,398,709 | private boolean processar(int iCodProd) {
String sSQL = null;
String sSQLCompra = null;
String sSQLInventario = null;
String sSQLVenda = null;
String sSQLRMA = null;
String sSQLOP = null;
String sSQLOP_SP = null;
String sWhere = null;
String sP... | 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,153 | 11,346,792 | 1,142,776 | public void generate(FileObject outputDirectory, FileObject generatedOutputDirectory, List<Library> libraryModels, String tapdocXml) throws FileSystemException {
if (!generatedOutputDirectory.exists()) {
generatedOutputDirectory.createFolder();
}
if (outputDirectory.exists()) {
... | public LinkedList<NameValuePair> getScoreboard() {
InputStream is = null;
String result = "";
LinkedList<NameValuePair> scores = new LinkedList<NameValuePair>();
try {
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(domain);
... | false |
4,154 | 1,044,656 | 7,047,049 | public void open(String server, String user, String pass, int port, String option) throws Exception {
log.info("Login to FTP: " + server);
this.port = port;
ftp = new FTPClient();
ftp.connect(server, port);
ftp.login(user, pass);
checkReply("FTP server refused connect... | public URL grabCover(String artist, String title) {
if (idf.jCheckBox3.isSelected()) {
println("Searching cover for: " + artist);
artist = artist.trim();
URL url = null;
int searchnumber = 0;
try {
URL yahoo = new URL("http://www.gr... | false |
4,155 | 3,180,675 | 254,725 | public void copyDependancyFiles() {
for (String[] depStrings : getDependancyFiles()) {
String source = depStrings[0];
String target = depStrings[1];
try {
File sourceFile = PluginManager.getFile(source);
IOUtils.copyEverything(sourceFile, n... | 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;
... | false |
4,156 | 4,130,551 | 5,636,800 | private byte[] streamToBytes(InputStream in) throws IOException {
ByteArrayOutputStream out = new ByteArrayOutputStream();
try {
IOUtils.copy(in, out);
} finally {
IOUtils.closeQuietly(in);
}
return out.toByteArray();
}
| public static void main(String[] args) throws IOException {
System.setProperty("java.protocol.xfile", "com.luzan.common.nfs");
if (args.length < 1) usage();
final String cmd = args[0];
if ("delete".equalsIgnoreCase(cmd)) {
final String path = getParameter(args, 1);
... | true |
4,157 | 21,898,978 | 13,845,913 | 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());
... | public synchronized boolean copyTmpDataFile(String fpath) throws IOException {
if (tmpDataOutput != null) tmpDataOutput.close();
tmpDataOutput = null;
if (tmpDataFile == null) return false;
File nfp = new File(fpath);
if (nfp.exists()) nfp.delete();
FileInputStream sr... | false |
4,158 | 7,464,994 | 4,892,654 | public void alterarQuestaoDiscursiva(QuestaoDiscursiva q) throws SQLException {
PreparedStatement stmt = null;
String sql = "UPDATE discursiva SET gabarito=? WHERE id_questao=?";
try {
stmt = conexao.prepareStatement(sql);
stmt.setString(1, q.getGabarito());
... | public void test(TestHarness harness) {
harness.checkPoint("TestOfMD4");
try {
Security.addProvider(new JarsyncProvider());
algorithm = MessageDigest.getInstance("BrokenMD4", "JARSYNC");
} catch (Exception x) {
harness.debug(x);
harness.fail("T... | false |
4,159 | 414,463 | 3,657,883 | 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... | @Override
public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException {
String context = request.getContextPath();
String resource = request.getRequestURI().replace(context, "");
resource = resource.replaceAll("^/\\w*/", "");
... | true |
4,160 | 3,024,989 | 23,029,916 | @Test
public void testCopy_readerToOutputStream_Encoding_nullOut() throws Exception {
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStreamTest(in);
Reader reader = new InputStreamReader(in, "US-ASCII");
try {
IOUtils.copy(reader, (OutputS... | public static void notify(String msg) throws Exception {
String url = "http://api.clickatell.com/http/sendmsg?";
url = add(url, "user", user);
url = add(url, "password", password);
url = add(url, "api_id", apiId);
url = add(url, "to", to);
url = add(url, "text", msg);... | true |
4,161 | 413,562 | 8,979,065 | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | public void copyFile(File source, File destination) {
try {
FileInputStream sourceStream = new FileInputStream(source);
try {
FileOutputStream destinationStream = new FileOutputStream(destination);
try {
FileChannel sourceChannel = ... | true |
4,162 | 970,144 | 3,400,236 | public Logging() throws Exception {
File home = new File(System.getProperty("user.home"), ".jorgan");
if (!home.exists()) {
home.mkdirs();
}
File logging = new File(home, "logging.properties");
if (!logging.exists()) {
InputStream input = getClass().ge... | 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... | false |
4,163 | 265,214 | 12,908,231 | 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;
... | private void readFromStorableInput(String filename) {
try {
URL url = new URL(getCodeBase(), filename);
InputStream stream = url.openStream();
StorableInput input = new StorableInput(stream);
fDrawing.release();
fDrawing = (Drawing) input.readStora... | false |
4,164 | 10,391,639 | 15,669,668 | 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... | private static FileChannel getFileChannel(File file, boolean isOut, boolean append) throws OpenR66ProtocolSystemException {
FileChannel fileChannel = null;
try {
if (isOut) {
FileOutputStream fileOutputStream = new FileOutputStream(file.getPath(), append);
... | true |
4,165 | 6,214,338 | 6,085,930 | private File unzipArchive(File zipArchive, File outDir, String nameInZipArchive) throws IOException {
File mainFile = null;
ZipEntry entry = null;
ZipInputStream zis = new ZipInputStream(new FileInputStream((zipArchive)));
FileOutputStream fos = null;
byte buffer[] = new byte... | public void update() {
if (!updatable) {
Main.fenetre().erreur(Fenetre.OLD_VERSION);
return;
}
try {
Main.fenetre().update();
Element remoteRoot = new SAXBuilder().build(xml).getRootElement();
addPackages = new HashMap<Integer, Pack... | true |
4,166 | 21,958,776 | 19,436,818 | public void filter(File source, File destination, MNamespace mNamespace) throws Exception {
BufferedReader reader = new BufferedReader(new FileReader(source));
BufferedWriter writer = new BufferedWriter(new FileWriter(destination));
int line = 0;
int column = 0;
Stack parseSt... | private void collectImageFile(@NotNull final Progress progress, @NotNull final File collectedDirectory) throws IOException {
final File file = new File(collectedDirectory, ActionBuilderUtils.getString(ACTION_BUILDER, "configSource.image.name"));
final FileOutputStream fos = new FileOutputStream(file... | true |
4,167 | 15,588,201 | 23,247,734 | public void copy(File source, File destination) {
try {
FileInputStream fileInputStream = new FileInputStream(source);
FileOutputStream fileOutputStream = new FileOutputStream(destination);
FileChannel inputChannel = fileInputStream.getChannel();
FileChannel o... | public static void main(String[] args) throws MalformedURLException, IOException {
InputStream in = null;
try {
in = new URL("hdfs://localhost:8020/user/leeing/maxtemp/sample.txt").openStream();
IOUtils.copyBytes(in, System.out, 8192, false);
} finally {
I... | true |
4,168 | 23,310,399 | 15,211,815 | 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... | private static boolean hasPackageInfo(URL url) {
if (url == null) return false;
BufferedReader br = null;
try {
br = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line = br.readLine()) != null) {
if (line... | false |
4,169 | 1,931,703 | 16,634,836 | public GPSTrace loadGPSTrace(long reportID) {
try {
URL url = new URL(SERVER_URL + XML_PATH + "gps.xml");
System.out.println(url);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
... | @Test
public void mockingURLWorks() throws Exception {
URL url = mock(URL.class);
URLConnection urlConnectionMock = mock(URLConnection.class);
when(url.openConnection()).thenReturn(urlConnectionMock);
URLConnection openConnection = url.openConnection();
assertSame(openCon... | false |
4,170 | 170,006 | 17,638,222 | 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 void copyFile(final File sourceFile, final File destFile) throws IOException {
if (!destFile.exists()) destFile.createNewFile();
FileChannel source = null;
FileChannel destination = null;
try {
source = new FileInputStream(sourceFile).getChannel();
... | false |
4,171 | 15,964,688 | 21,570,957 | public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("LOAD")) {
JFileChooser chooser = new JFileChooser();
chooser.setFileFilter(new JPEGFilter());
chooser.setMultiSelectionEnabled(false);
if (chooser.showOpenDialog(getTopLevelAncestor(... | private static long saveAndClosePDFDocument(PDDocument document, OutputStreamProvider outProvider) throws IOException, COSVisitorException {
File tempFile = null;
InputStream in = null;
OutputStream out = null;
try {
tempFile = File.createTempFile("temp", "pdf");
... | true |
4,172 | 5,613,811 | 10,115,624 | @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
list = (ListView) findViewById(R.id.list);
db = new DBAdapter(this);
news = new ArrayList<Data>();
adapter = new NewsAdapter(news);
... | public void registerSchema(String newSchemaName, String objectControlller, long boui, String expression, String schema) throws SQLException {
Connection cndef = null;
PreparedStatement pstm = null;
try {
cndef = this.getRepositoryConnection(p_ctx.getApplication(), "default", 2);
... | false |
4,173 | 13,279,965 | 10,912,333 | public static void fileUpload() throws IOException {
HttpClient httpclient = new DefaultHttpClient();
httpclient.getParams().setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
file = new File("H:\\FileServeUploader.java");
HttpPost httppost = new HttpPost(postUR... | public void guardarRecordatorio() {
try {
if (espaciosLlenos()) {
guardarCantidad();
String dat = "";
String filenametxt = String.valueOf("recordatorio" + cantidadArchivos + ".txt");
String filenamezip = String.valueOf("recordatorio... | false |
4,174 | 11,604,443 | 169,612 | private void getRandomGUID(boolean secure) {
MessageDigest md5 = null;
StringBuffer sbValueBeforeMD5 = new StringBuffer(128);
try {
md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
logger.error("Error: " + e);
}
tr... | public String encrypt(String plaintext) {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA");
} catch (NoSuchAlgorithmException e) {
System.err.println(e.getMessage());
}
try {
md.update(plaintext.getBytes("UTF-8"));
... | true |
4,175 | 14,434,675 | 4,056,440 | private void updateDataSetSelected(URL url) {
InputStream in = null;
try {
in = url.openStream();
StringBuilder sb = new StringBuilder();
int by = in.read();
while (by != -1) {
sb.append((char) by);
by = in.read();
... | public final String hashPassword(final String password) {
try {
if (salt == null) {
salt = new byte[16];
SecureRandom sr = SecureRandom.getInstance("SHA1PRNG");
sr.setSeed(System.currentTimeMillis());
sr.... | false |
4,176 | 3,167,464 | 21,680,551 | public void adicionaCliente(ClienteBean cliente) {
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "insert into cliente(nome,cpf,telefone,cursoCargo,bloqueado,ativo,tipo) values(?,?,?,?,?,?,?)";
try {
pstmt = connection.prepareStatement(sql, Statement.RE... | private static File createTempWebXml(Class portletClass, File portletDir, String appName, String portletName) throws IOException, FileNotFoundException {
File pathToWebInf = new File(portletDir, "WEB-INF");
File tempWebXml = File.createTempFile("web", ".xml", pathToWebInf);
tempWebXml.delete... | false |
4,177 | 555,928 | 19,731,419 | private static File copyFileTo(File file, File directory) throws IOException {
File newFile = new File(directory, file.getName());
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(file);
fos = new FileOutputStream(newFil... | public void transport(File file) throws TransportException {
if (file.exists()) {
if (file.isDirectory()) {
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) {
transport(file);
}
} else if (file... | true |
4,178 | 6,847,452 | 4,341,090 | 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... | public Object run() {
if (type == GET_THEME_DIR) {
String sep = File.separator;
String[] dirs = new String[] { userHome + sep + ".themes", System.getProperty("swing.metacitythemedir"), "/usr/share/themes", "/usr/gnome/share/themes", "/opt/gnome2/share/themes" };
... | false |
4,179 | 15,659,812 | 10,329,098 | private static void generateTIFF(Connection con, String category, String area_code, String topic_code, String timeseries, String diff_timeseries, Calendar time, String area_label, String raster_label, String image_label, String note, Rectangle2D bounds, Rectangle2D raster_bounds, String source_filename, String diff... | public void setPilot(PilotData pilotData) throws UsernameNotValidException {
try {
if (pilotData.username.trim().equals("") || pilotData.password.trim().equals("")) throw new UsernameNotValidException(1, "Username or password missing");
PreparedStatement psta;
if (pilotDa... | true |
4,180 | 12,879,117 | 16,548,896 | protected String insertCommand(String command) throws ServletException {
String digest;
try {
MessageDigest md = MessageDigest.getInstance(m_messagedigest_algorithm);
md.update(command.getBytes());
byte bytes[] = new byte[20];
m_random.nextBytes(bytes)... | private String generateHash(String key, String data) throws ChiropteraException {
try {
MessageDigest md = MessageDigest.getInstance(Constants.Connection.Auth.MD5);
md.update(key.getBytes());
byte[] raw = md.digest();
String s = toHexString(raw);
S... | true |
4,181 | 10,937,054 | 19,016,407 | public static void main(String[] args) {
FTPClient client = new FTPClient();
FileInputStream fis = null;
try {
client.connect("192.168.1.10");
client.login("a", "123456");
String filename = "D:\\DHTH5CLT\\HK3\\Ung dung phan tan\\FTP_JAVA\\FTP_DETAI\\FTP\\s... | public int print(String type, String url, String attrs) throws PrinterException {
try {
return print(type, (new URL(url)).openStream(), attrs);
} catch (Exception e) {
e.printStackTrace();
throw new PrinterException(e);
}
}
| false |
4,182 | 11,904,774 | 1,677,217 | public void testFileSystem() throws IOException {
Fragment f = Fragment.EMPTY;
Fragment g = f.plus(System.getProperty("java.io.tmpdir"));
Fragment h = f.plus("april", "1971", "data.txt");
Fragment i = f.plus(g, h);
InOutLocation iol = locs.fs.plus(i);
PrintStream ps =... | @Override
protected final void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
if (beforeServingFile(req, resp)) {
String pathInfo = req.getPathInfo();
Validate.notNull(pathInfo, "the path info is null -> the sevlet should be mapped ... | false |
4,183 | 12,747,342 | 23,611,768 | public void bubbleSort(final int[] s) {
source = s;
if (source.length < 2) return;
boolean go = true;
while (go) {
go = false;
for (int i = 0; i < source.length - 1; i++) {
int temp = source[i];
if (temp > source[i + 1]) {
... | 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(... | false |
4,184 | 3,086,853 | 9,564,133 | protected Icon newIcon(String iconName) {
URL url = Utils.getResource(getFullPath(iconName, "/"), getClass());
if (url == null) {
if (getParent() != null) return getParent().getIcon(iconName);
return null;
}
try {
MethodCall getImage = new MethodCa... | public void copy(File aSource, File aDestDir) throws IOException {
FileInputStream myInFile = new FileInputStream(aSource);
FileOutputStream myOutFile = new FileOutputStream(new File(aDestDir, aSource.getName()));
FileChannel myIn = myInFile.getChannel();
FileChannel myOut = myOutFil... | false |
4,185 | 15,376,881 | 17,200,624 | 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... | public void run() {
runCounter++;
try {
LOGGER.info("Fetching feed [" + runCounter + "] " + _feedInfo);
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpContext localContext = new BasicHttpContext();
disableSSLCertificateChecking(httpClient)... | false |
4,186 | 11,352,932 | 4,431,397 | public String generateFilename() {
MessageDigest md;
byte[] sha1hash = new byte[40];
Random r = new Random();
String fileName = "";
String token = "";
while (true) {
token = Long.toString(Math.abs(r.nextLong()), 36) + Long.toString(System.currentTimeMillis... | private void processar() {
boolean bOK = false;
String sSQL = "DELETE FROM FNSALDOLANCA WHERE CODEMP=? AND CODFILIAL=?";
try {
state("Excluindo base atual de saldos...");
PreparedStatement ps = con.prepareStatement(sSQL);
ps.setInt(1, Aplicativo.iCodEmp);
... | false |
4,187 | 10,793,895 | 8,523,656 | protected void configure() {
Enumeration<URL> resources = null;
try {
resources = classLoader.getResources(resourceName);
} catch (IOException e) {
binder().addError(e.getMessage(), e);
return;
}
int resourceCount = 0;
while (resour... | public String getRssFeedUrl(boolean searchWeb) {
String rssFeedUrl = null;
if (entity.getNewsFeedUrl() != null & !entity.getUrl().equals("")) {
return entity.getNewsFeedUrl();
} else if (entity.getUrl() == null || entity.getUrl().equals("")) {
return entity.getNewsFee... | false |
4,188 | 19,579,830 | 78,966 | public static void copy(File toCopy, File dest) throws IOException {
FileInputStream src = new FileInputStream(toCopy);
FileOutputStream out = new FileOutputStream(dest);
try {
while (src.available() > 0) {
out.write(src.read());
}
} finally {
... | 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,189 | 2,746,011 | 16,466,519 | @RequestMapping(value = "/privatefiles/{file_name}")
public void getFile(@PathVariable("file_name") String fileName, HttpServletResponse response, Principal principal) {
try {
Boolean validUser = false;
final String currentUser = principal.getName();
Authentication au... | 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,190 | 7,067,836 | 13,883,878 | private String generateFilename() {
byte[] hash = null;
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
try {
digest.update(InetAddress.getLocalHost().toString().getBytes());
} catch (UnknownHostException e) {
}
... | PathElement(String path) throws MaxError {
this.path = path;
if (path.startsWith("http:")) {
try {
url = new URL(path);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("HEAD... | false |
4,191 | 492,308 | 2,150,993 | public In(String s) {
try {
File file = new File(s);
if (file.exists()) {
scanner = new Scanner(file, charsetName);
scanner.useLocale(usLocale);
return;
}
URL url = getClass().getResource(s);
if (url ... | public static void main(String[] args) {
if (args.length <= 0) {
System.out.println(" *** SQL script generator and executor ***");
System.out.println(" You must specify name of the file with SQL script data");
System.out.println(" Fisrt rows of this file must be:");
... | false |
4,192 | 10,927,077 | 9,983,984 | private String hash(String message) {
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA1");
} catch (NoSuchAlgorithmException e) {
throw new AssertionError("Can't find the SHA1 algorithm in the java.security package");
}
String saltStr... | private 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,193 | 288,978 | 11,200,354 | private static void readAndRewrite(File inFile, File outFile) throws IOException {
ImageInputStream iis = ImageIO.createImageInputStream(new BufferedInputStream(new FileInputStream(inFile)));
DcmParser dcmParser = DcmParserFactory.getInstance().newDcmParser(iis);
Dataset ds = DcmObjectFactor... | private boolean authenticate(String reply) {
String user = reply.substring(0, reply.indexOf(" "));
String resp = reply.substring(reply.indexOf(" ") + 1);
if (!module.users.contains(user)) {
error = "so such user " + user;
return false;
}
try {
... | false |
4,194 | 320,979 | 7,149,321 | public void convert(File src, File dest) throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(src));
DcmParser p = pfact.newDcmParser(in);
Dataset ds = fact.newDataset();
p.setDcmHandler(ds.getDcmHandler());
try {
FileFormat format = p... | public static Dimension getJPEGDimension(String urls) throws IOException {
URL url;
Dimension d = null;
try {
url = new URL(urls);
InputStream fis = url.openStream();
if (fis.read() != 255 || fis.read() != 216) throw new RuntimeException("SOI (Start Of Ima... | false |
4,195 | 15,497,380 | 10,293,577 | public static String generateSig(Map<String, String> params, String secret) {
SortedSet<String> keys = new TreeSet<String>(params.keySet());
keys.remove(FacebookParam.SIGNATURE.toString());
String str = "";
for (String key : keys) {
str += key + "=" + params.get(key);
... | private void getRandomGUID(boolean secure) {
MessageDigest md5 = null;
StringBuffer sbValueBeforeMD5 = new StringBuffer();
try {
md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
}
try {
long time = System.currentTi... | true |
4,196 | 13,776,078 | 20,282,670 | private GmailContact convertContactToGmailContact(Contact contact) throws GmailManagerException {
boolean homePhone = false, homePhone2 = false, homeFax = false, homeMobile = false, homePager = false;
boolean businessPhone = false, businessPhone2 = false, businessFax = false, businessMobile = false,... | public void downloadFtpFile(SynchrnServerVO synchrnServerVO, String fileNm) throws Exception {
FTPClient ftpClient = new FTPClient();
ftpClient.setControlEncoding("euc-kr");
if (!EgovWebUtil.isIPAddress(synchrnServerVO.getServerIp())) {
throw new RuntimeException("IP is needed. (... | false |
4,197 | 20,037,616 | 2,168,608 | private void serializeWithClass(Class theClass, int count, String comment) {
for (int c = 0; c < 10; c++) {
if (c == 9) {
beginAction(1, "persistence write/read", count, comment);
}
String tempFile = ".tmp.archive";
SerializeClassInterface theI... | public int delete(BusinessObject o) throws DAOException {
int delete = 0;
Contact contact = (Contact) o;
try {
PreparedStatement pst = connection.prepareStatement(XMLGetQuery.getQuery("DELETE_CONTACT"));
pst.setInt(1, contact.getId());
delete = pst.execute... | false |
4,198 | 8,909,675 | 14,138,097 | public static boolean copyFileToDir(File inputFile, File outputDir) {
try {
String outputFileName = inputFile.getName();
int index = 1;
while (existFileInDir(outputFileName, outputDir)) {
outputFileName = index + inputFile.getName();
index+... | public static void copy(File src, File dest) throws IOException {
if (dest.exists() && dest.isFile()) {
logger.fine("cp " + src + " " + dest + " -- Destination file " + dest + " already exists. Deleting...");
dest.delete();
}
final File parent = dest.getParentFile();
... | true |
4,199 | 11,710,005 | 5,590,065 | public static void main(String[] args) {
try {
URL url = new URL("http://www.lineadecodigo.com");
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(url.openStream()));
} catch (Throwable t) {
}
... | protected String readFileUsingHttp(String fileUrlName) {
String response = "";
try {
URL url = new URL(fileUrlName);
URLConnection connection = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) connection;
httpConn.setRequestProper... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.