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 |
|---|---|---|---|---|---|
3,500 | 22,993,367 | 7,670,003 | 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.... | @Override
public Object execute(ExecutionEvent event) throws ExecutionException {
URL url;
try {
url = new URL("platform:/plugin/de.vogella.rcp.plugin.filereader/files/test.txt");
InputStream inputStream = url.openConnection().getInputStream();
BufferedReader ... | false |
3,501 | 21,556,191 | 1,543,362 | public JTree createTree() {
DefaultMutableTreeNode top = new DefaultMutableTreeNode("Contents");
DefaultMutableTreeNode[] nodeLevels = new DefaultMutableTreeNode[0];
URL url = ResourceManager.getResource("tree.txt");
try {
InputStream is = url.openStream();
In... | public ProgramSymbol deleteProgramSymbol(int id) throws AdaptationException {
ProgramSymbol programSymbol = null;
Connection connection = null;
Statement statement = null;
ResultSet resultSet = null;
try {
String query = "SELECT * FROM ProgramSymbols " + "WHERE id... | false |
3,502 | 10,893,111 | 10,385,493 | public static void copyFile(File in, File out) throws IOException {
try {
FileReader inf = new FileReader(in);
OutputStreamWriter outf = new OutputStreamWriter(new FileOutputStream(out), "UTF-8");
int c;
while ((c = inf.read()) != -1) outf.write(c);
... | public void writeBack(File destinationFile, boolean makeCopy) throws IOException {
if (makeCopy) {
FileChannel sourceChannel = new java.io.FileInputStream(getFile()).getChannel();
FileChannel destinationChannel = new java.io.FileOutputStream(destinationFile).getChannel();
... | true |
3,503 | 15,209,427 | 20,325,581 | private void bokActionPerformed(java.awt.event.ActionEvent evt) {
if (this.tfGeneralSubDivision.getText().trim().equals("")) {
this.showWarningMessage("Enter general sub division");
} else {
String[] patlib = newgen.presentation.NewGenMain.getAppletInstance().getPatronLibrary... | public static byte[] generateHash(String strPassword, byte[] salt) {
try {
MessageDigest md = MessageDigest.getInstance(HASH_ALGORITHM);
md.update(strPassword.getBytes(CHAR_ENCODING));
md.update(salt);
return md.digest();
} catch (Exception e) {
... | false |
3,504 | 18,540,660 | 22,366,639 | private static URLConnection connectToNCBIValidator() throws IOException {
final URL url = new URL(NCBI_URL);
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setRequestProperty("Content-Type", CONTENT_TYPE... | public int update(BusinessObject o) throws DAOException {
int update = 0;
Project project = (Project) o;
try {
PreparedStatement pst = connection.prepareStatement(XMLGetQuery.getQuery("UPDATE_PROJECT"));
pst.setString(1, project.getName());
pst.setString(2... | false |
3,505 | 10,287,987 | 7,232,355 | 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 String replace(URL url, Replacer replacer) throws Exception {
URLConnection con = url.openConnection();
InputStreamReader reader = new InputStreamReader(con.getInputStream());
StringWriter wr = new StringWriter();
int c;
StringBuffer token = null;
while ... | false |
3,506 | 23,035,538 | 2,067,794 | public static void main(String[] args) {
try {
String user = "techbeherca";
String targetUrl = "http://api.fanfou.com/statuses/user_timeline.xml?id=" + user;
URL url = new URL(targetUrl);
InputStream in = url.openStream();
ArrayList<MessageObj> lis... | public SingularValueDecomposition(Matrix Arg) {
double[][] A = Arg.getArrayCopy();
m = Arg.getRowDimension();
n = Arg.getColumnDimension();
int nu = Math.min(m, n);
s = new double[Math.min(m + 1, n)];
U = new double[m][nu];
V = new double[n][n];
double... | false |
3,507 | 23,165,929 | 736,738 | private void createCanvas() {
GraphicalViewer viewer = new ScrollingGraphicalViewer();
viewer.setRootEditPart(new ScalableRootEditPart());
viewer.setEditPartFactory(new BlockEditPartFactory());
viewer.createControl(this);
viewer.setKeyHandler(new GraphicalViewerKeyHandler(vie... | public void convert(File src, File dest) throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(src));
DcmParser p = pfact.newDcmParser(in);
Dataset ds = fact.newDataset();
p.setDcmHandler(ds.getDcmHandler());
try {
FileFormat format = p... | false |
3,508 | 2,386,120 | 18,489,831 | @Override
public void setContentAsStream(InputStream input) throws IOException {
BufferedOutputStream output = new BufferedOutputStream(new FileOutputStream(htmlFile));
try {
IOUtils.copy(input, output);
} finally {
output.close();
}
if (this.getLa... | private static URL downloadFile(URL url, File destFile) throws Exception {
try {
URLConnection urlConnection = url.openConnection();
File tmpFile = null;
try {
tmpFile = File.createTempFile("remoteLib_", null);
InputStream in = null;
... | true |
3,509 | 14,635,922 | 7,005,226 | public String contactService(String service, StringBuffer xmlRequest) throws Exception {
Logger.debug(UPSConnections.class, "UPS CONNECTIONS ***** Started " + service + " " + new Date().toString() + " *****");
HttpURLConnection connection;
URL url;
String response = "";
try {... | private void copyValidFile(File file, int cviceni) {
try {
String filename = String.format("%s%s%02d%s%s", validovane, File.separator, cviceni, File.separator, file.getName());
boolean copy = false;
File newFile = new File(filename);
if (newFile.exists()) {
... | false |
3,510 | 13,405,484 | 16,529,002 | public boolean send(String number, String message) throws IOException {
init();
message = message.substring(0, Math.min(MAX_PAYLOAD, message.length()));
message = message.replace('\r', ' ');
message = message.replace('\n', ' ');
ActualFormParameters params = new ActualFormPar... | public static boolean copy(File source, File dest) {
FileChannel in = null, out = null;
try {
in = new FileInputStream(source).getChannel();
out = new FileOutputStream(dest).getChannel();
long size = in.size();
MappedByteBuffer buf = in.map(FileChannel... | false |
3,511 | 14,945,924 | 687,106 | public static String hashPassword(String password) {
String hashword = null;
try {
MessageDigest md5 = MessageDigest.getInstance(MESSAGE_DIGEST_ALGORITHM_MD5);
md5.update(password.getBytes());
BigInteger hash = new BigInteger(1, md5.digest());
hashword... | public boolean copyDirectoryTree(File srcPath, File dstPath) {
try {
if (srcPath.isDirectory()) {
if (!dstPath.exists()) dstPath.mkdir();
String files[] = srcPath.list();
for (int i = 0; i < files.length; i++) copyDirectoryTree(new File(srcPath, fi... | false |
3,512 | 3,109,682 | 1,327,097 | @SmallTest
public void testSha1() throws Exception {
MessageDigest digest = MessageDigest.getInstance("SHA-1");
int numTests = mTestData.length;
for (int i = 0; i < numTests; i++) {
digest.update(mTestData[i].input.getBytes());
byte[] hash = digest.digest();
... | public String generateMappackMD5(File mapPackFile) throws IOException, NoSuchAlgorithmException {
ZipFile zip = new ZipFile(mapPackFile);
try {
Enumeration<? extends ZipEntry> entries = zip.entries();
MessageDigest md5Total = MessageDigest.getInstance("MD5");
Mess... | true |
3,513 | 210,587 | 14,190,765 | 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 void _PostParser(Document document, AnnotationManager annoMan, Document htmldoc, String baseurl) {
xformer = annoMan.getTransformer();
builder = annoMan.getBuilder();
String annohash = "";
if (document == null) return;
NodeList ndlist = document.getElementsByTagNameNS... | false |
3,514 | 4,076,629 | 10,287,986 | public void uploadFile(String filename) throws RQLException {
checkFtpClient();
OutputStream out = null;
try {
out = ftpClient.storeFileStream(filename);
IOUtils.copy(new FileReader(filename), out);
out.close();
ftpClient.completePendingCommand... | 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 |
3,515 | 2,265,495 | 14,918,000 | public final String encrypt(String input) throws Exception {
try {
MessageDigest messageDigest = (MessageDigest) MessageDigest.getInstance(algorithm).clone();
messageDigest.reset();
messageDigest.update(input.getBytes());
String output = convert(messageDigest.... | public void invoke(MessageContext msgContext) throws AxisFault {
log.debug("Enter: MD5AttachHandler::invoke");
try {
Message msg = msgContext.getRequestMessage();
SOAPConstants soapConstants = msgContext.getSOAPConstants();
org.apache.axis.message.SOAPEnvelope env... | true |
3,516 | 20,987,825 | 361,255 | public void run() {
try {
URL read = null;
if (_readURL.indexOf("?") >= 0) {
read = new URL(_readURL + "&id=" + _id);
} else {
read = new URL(_readURL + "?id=" + _id);
}
while (_keepGoing) {
String li... | private void displayDiffResults() throws IOException {
File outFile = File.createTempFile("diff", ".htm");
outFile.deleteOnExit();
FileOutputStream outStream = new FileOutputStream(outFile);
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outStream));
out.write... | false |
3,517 | 22,728,535 | 1,677,217 | public void actionPerformed(java.awt.event.ActionEvent e) {
JFileChooser fc = new JFileChooser();
fc.addChoosableFileFilter(new ImageFilter());
fc.setAccessory(new ImagePreview(fc));
int returnVal = fc.showDialog(Administrac... | @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 ... | true |
3,518 | 12,816,475 | 18,661,682 | protected void writePage(final CacheItem entry, final TranslationResponse response, ModifyTimes times) throws IOException {
if (entry == null) {
return;
}
Set<ResponseHeader> headers = new TreeSet<ResponseHeader>();
for (ResponseHeader h : entry.getHeaders()) {
... | public static OMElement createOMRequest(String file, int count, String[] documentIds) throws Exception {
ObjectFactory factory = new ObjectFactory();
SubmitDocumentRequest sdr = factory.createSubmitDocumentRequest();
IdType pid = factory.createIdType();
pid.setRoot("1.3.6.1.4.1.21367... | true |
3,519 | 12,718,571 | 8,001,867 | private ArrayList loadHTML(URL url) {
ArrayList res = new ArrayList();
try {
URLConnection myCon = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(myCon.getInputStream()));
String inputLine;
while ((inputLine = in.rea... | private void nioBuild() {
try {
final ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 4);
final FileChannel out = new FileOutputStream(dest).getChannel();
for (File part : parts) {
setState(part.getName(), BUILDING);
FileChannel in = n... | false |
3,520 | 8,249,982 | 6,096,495 | public void getDownloadInfo(String _url) throws Exception {
URL url = new URL(_url);
con = (HttpURLConnection) url.openConnection();
con.setRequestProperty("User-Agent", "test");
con.setRequestProperty("Accept", "*/*");
con.setRequestProperty("Range", "bytes=0-");
con... | public String getMD5(String password) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(password.getBytes());
byte byteData[] = md.digest();
StringBuffer sb = new StringBuffer();
for(int i = 0; i < byteData.length; i++) {
sb.append(Integer.toString((byteData[... | false |
3,521 | 7,093,300 | 20,860,648 | public static InputStream getRequest(String path) throws Exception {
HttpGet httpGet = new HttpGet(path);
HttpResponse httpResponse = sClient.execute(httpGet);
if (httpResponse.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
BufferedHttpEntity bufHttpEntity = new BufferedHttpEntity(httpResponse.getEnti... | protected void copy(File source, File destination) throws IOException {
final FileChannel inChannel = new FileInputStream(source).getChannel();
final FileChannel outChannel = new FileOutputStream(destination).getChannel();
try {
inChannel.transferTo(0, inChannel.size(), outChanne... | false |
3,522 | 6,596,328 | 17,832,320 | public static String getSHA1Hash(String plainText) throws NoSuchAlgorithmException {
MessageDigest md = MessageDigest.getInstance("SHA1");
md.update(plainText.getBytes());
byte[] mdbytes = md.digest();
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < mdbytes.l... | public void run() {
Pair p = null;
try {
while ((p = queue.pop()) != null) {
GetMethod get = new GetMethod(p.getRemoteUri());
try {
get.setFollowRedirects(true);
get.setRequestHeader("Mariner-Application", "prerender... | false |
3,523 | 19,645,662 | 9,265,781 | public void notifyIterationEnds(final IterationEndsEvent event) {
log.info("moving files...");
File source = new File("deqsim.log");
if (source.exists()) {
File destination = new File(Controler.getIterationFilename("deqsim.log"));
if (!IOUtils.renameFile(source, desti... | public static void copy(String from_name, String to_name) throws IOException {
File from_file = new File(from_name);
File to_file = new File(to_name);
if (!from_file.exists()) abort("FileCopy: no such source file: " + from_name);
if (!from_file.isFile()) abort("FileCopy: can't copy d... | true |
3,524 | 11,081,583 | 778,641 | public void rename(String virtualWiki, String oldTopicName, String newTopicName) throws Exception {
Connection conn = DatabaseConnection.getConnection();
try {
boolean commit = false;
conn.setAutoCommit(false);
try {
PreparedStatement pstm = conn.p... | public void convert(File src, File dest) throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(src));
DcmParser p = pfact.newDcmParser(in);
Dataset ds = fact.newDataset();
p.setDcmHandler(ds.getDcmHandler());
try {
FileFormat format = p... | false |
3,525 | 2,284,080 | 17,212,288 | private static void copy(String srcFilename, String dstFilename, boolean override) throws IOException, XPathFactoryConfigurationException, SAXException, ParserConfigurationException, XPathExpressionException {
File fileToCopy = new File(rootDir + "test-output/" + srcFilename);
if (fileToCopy.exists(... | private void copyFile(File source, File destination) throws IOException {
FileInputStream fileInputStream = null;
FileOutputStream fileOutputStream = null;
try {
fileInputStream = new FileInputStream(source);
fileOutputStream = new FileOutputStream(destination);
... | true |
3,526 | 3,691,986 | 765,103 | public static void copyFile(HttpServletResponse response, String file) throws IOException {
response.setContentType(FileUtils.getContentType(file));
response.setContentLength(FileUtils.getContentLength(file));
response.setHeader("Content-Length", Integer.toString(FileUtils.getContentLength(f... | 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 |
3,527 | 20,200,144 | 7,682,647 | public void copyFile(final File sourceFile, final File destinationFile) throws FileIOException {
final FileChannel sourceChannel;
try {
sourceChannel = new FileInputStream(sourceFile).getChannel();
} catch (FileNotFoundException exception) {
final String message = COP... | public static void copyFile(String oldPathFile, String newPathFile) {
try {
int bytesum = 0;
int byteread = 0;
File oldfile = new File(oldPathFile);
if (oldfile.exists()) {
InputStream inStream = new FileInputStream(oldPathFile);
... | true |
3,528 | 14,563,781 | 1,708,100 | public static void parseString(String str, String name) {
BufferedReader reader;
String zeile = null;
boolean firstL = true;
int lambda;
float intens;
int l_b = 0;
int l_e = 0;
HashMap<Integer, Float> curve = new HashMap<Integer, Float>();
Stri... | private void sendFile(File file, HttpExchange response) throws IOException {
response.getResponseHeaders().add(FileUploadBase.CONTENT_LENGTH, Long.toString(file.length()));
InputStream inputStream = null;
try {
inputStream = new FileInputStream(file);
IOUtils.copy(inp... | true |
3,529 | 1,708,100 | 15,669,668 | private void sendFile(File file, HttpExchange response) throws IOException {
response.getResponseHeaders().add(FileUploadBase.CONTENT_LENGTH, Long.toString(file.length()));
InputStream inputStream = null;
try {
inputStream = new FileInputStream(file);
IOUtils.copy(inp... | 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 |
3,530 | 15,637,504 | 9,562,033 | @Override
protected void setUp() throws Exception {
this.logger = new ConsoleLogger(ConsoleLogger.LEVEL_WARN);
File repoFolder = new File("target/repository");
removeRepository(repoFolder);
InputStream repoConfigIn = getClass().getResourceAsStream(REPO_CONFIG_FILE);
File ... | public void run(String srcf, String dst) {
final Path srcPath = new Path("./" + srcf);
final Path desPath = new Path(dst);
try {
Path[] srcs = FileUtil.stat2Paths(hdfs.globStatus(srcPath), srcPath);
OutputStream out = FileSystem.getLocal(conf).create(desPath);
... | true |
3,531 | 2,532,321 | 11,142,914 | public static boolean encodeFileToFile(String infile, String outfile) {
boolean success = false;
java.io.InputStream in = null;
java.io.OutputStream out = null;
try {
in = new Base64.InputStream(new java.io.BufferedInputStream(new java.io.FileInputStream(infile)), Base64.... | private boolean copyAvecProgressNIO(File sRC2, File dEST2, JProgressBar progressEnCours) throws IOException {
boolean resultat = false;
FileInputStream fis = new FileInputStream(sRC2);
FileOutputStream fos = new FileOutputStream(dEST2);
java.nio.channels.FileChannel channelSrc = fis.... | true |
3,532 | 21,652,119 | 949,221 | protected void setupService(MessageContext msgContext) throws Exception {
String realpath = msgContext.getStrProp(Constants.MC_REALPATH);
String extension = (String) getOption(OPTION_JWS_FILE_EXTENSION);
if (extension == null) extension = DEFAULT_JWS_FILE_EXTENSION;
if ((realpath != ... | 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 |
3,533 | 210,587 | 369,572 | 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 void displayDiffResults() throws IOException {
File outFile = File.createTempFile("diff", ".htm");
outFile.deleteOnExit();
FileOutputStream outStream = new FileOutputStream(outFile);
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(outStream));
out.write... | true |
3,534 | 888,827 | 4,824,415 | 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 String encrypt(String algorithm, String[] input) {
try {
MessageDigest md = MessageDigest.getInstance(algorithm);
md.reset();
for (int i = 0; i < input.length; i++) {
if (input[i] != null) md.update(input[i].getBytes("UTF-8"));
}
... | false |
3,535 | 6,747,095 | 854,262 | public void notifyTerminated(Writer r) {
all_writers.remove(r);
if (all_writers.isEmpty()) {
all_terminated = true;
Iterator iterator = open_files.iterator();
while (iterator.hasNext()) {
FileWriter.FileChunk fc = (FileWriter.FileChunk) iterator.ne... | 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 |
3,536 | 1,322,369 | 13,893,663 | private void unpackBundle() throws IOException {
File useJarPath = null;
if (DownloadManager.isWindowsVista()) {
useJarPath = lowJarPath;
File jarDir = useJarPath.getParentFile();
if (jarDir != null) {
jarDir.mkdirs();
}
} else ... | public static int executeNoQuery(String strStatement) throws SQLException {
MyDBConnection myc = new MyDBConnection();
myc.init();
Statement statement = myc.getMyConnection().createStatement();
try {
int rows = statement.executeUpdate(strStatement);
myc.myConn... | false |
3,537 | 5,199,811 | 5,706,224 | public static String encodePassword(String password) {
try {
MessageDigest messageDiegest = MessageDigest.getInstance("SHA-1");
messageDiegest.update(password.getBytes("UTF-8"));
return Base64.encodeToString(messageDiegest.digest(), false);
} catch (NoSuchAlgorith... | public void run() {
try {
File outDir = new File(outDirTextField.getText());
if (!outDir.exists()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
JOptionPane.showMessageDialog(... | false |
3,538 | 20,924,120 | 12,477,501 | public static void gunzip() throws Exception {
System.out.println("gunzip()");
GZIPInputStream zipin = new GZIPInputStream(new FileInputStream("/zip/myzip.gz"));
byte buffer[] = new byte[BLOCKSIZE];
FileOutputStream out = new FileOutputStream("/zip/covers");
for (int length; ... | public HttpResponse execute(HttpUriRequest request, HttpContext context) throws IOException {
URI uri = request.getURI();
String original = uri.toString();
UrlRules rules = UrlRules.getRules(mResolver);
UrlRules.Rule rule = rules.matchRule(original);
String rewritten = rule.a... | false |
3,539 | 16,388,707 | 14,878,607 | 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 parse(InputStream stream, ContentHandler handler, Metadata metadata, ParseContext context) throws IOException, SAXException, TikaException {
String name = metadata.get(Metadata.RESOURCE_NAME_KEY);
if (name != null && wanted.containsKey(name)) {
FileOutputStrea... | true |
3,540 | 414,463 | 12,226,563 | 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 run() {
Vector<Update> updates = new Vector<Update>();
if (dic != null) updates.add(dic);
if (gen != null) updates.add(gen);
if (res != null) updates.add(res);
if (help != null) updates.add(help);
for (Iterator iterator = updates.iterator(); iterator.hasNe... | true |
3,541 | 18,675,737 | 22,480,999 | private void post(String title, Document content, Set<String> tags) throws HttpException, IOException, TransformerException {
PostMethod method = null;
try {
method = new PostMethod("http://www.blogger.com/feeds/" + this.blogId + "/posts/default");
method.addRequestHeader("GD... | @Test
public void testRegisterOwnJceProvider() throws Exception {
MyTestProvider provider = new MyTestProvider();
assertTrue(-1 != Security.addProvider(provider));
MessageDigest messageDigest = MessageDigest.getInstance("SHA-1", MyTestProvider.NAME);
assertEquals(MyTestProvider.N... | false |
3,542 | 13,212,350 | 169,612 | public static void copyFile(File source, File dest) {
try {
FileChannel in = new FileInputStream(source).getChannel();
if (!dest.getParentFile().exists()) dest.getParentFile().mkdirs();
FileChannel out = new FileOutputStream(dest).getChannel();
in.transferTo(0... | 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"));
... | false |
3,543 | 19,036,213 | 23,098,143 | private void createNodes() {
try {
URL url = this.getClass().getResource("NodesFile.txt");
InputStreamReader inReader = new InputStreamReader(url.openStream());
BufferedReader inNodes = new BufferedReader(inReader);
String s;
while ((s = inNodes.re... | public void process() {
try {
update("Shutdown knowledge base ...", 0);
DBHelper.shutdownDB();
update("Shutdown knowledge base ...", 9);
String zipDir = P.DIR.getPKBDataPath();
update("Backup in progress ...", 10);
List<String> fileList... | false |
3,544 | 11,572,565 | 4,364,579 | public static final boolean copy(File source, File target, boolean overwrite) {
if (!overwrite && target.exists()) {
LOGGER.error("Target file exist and it not permitted to overwrite it !");
return false;
}
FileChannel in = null;
FileChannel out = null;
... | public static String calcCRC(String phrase) {
StringBuffer crcCalc = new StringBuffer();
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(phrase.getBytes());
byte[] tabDigest = md.digest();
for (int i = 0; i < tabDigest.length; i++)... | false |
3,545 | 22,207,815 | 3,395,310 | public static Checksum checksum(File file, Checksum checksum) throws IOException {
if (file.isDirectory()) {
throw new IllegalArgumentException("Checksums can't be computed on directories");
}
InputStream in = null;
try {
in = new CheckedInputStream(new FileIn... | private void execute(File file) throws IOException {
if (file == null) throw new RuntimeException("undefined file");
if (!file.exists()) throw new RuntimeException("file not found :" + file);
if (!file.isFile()) throw new RuntimeException("not a file :" + file);
String login = cfg.ge... | true |
3,546 | 22,022,886 | 8,269,896 | public static String fetchURL(final String u) {
String retStr = "";
try {
final URL url = new URL(u);
final BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream()));
String line;
while ((line = reader.readLine()) != null) {
... | private String postData(String requestUrl, String atom) throws AuthenticationException, IOException {
URL url = new URL(requestUrl);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setDoOutput(true);
String header;
... | false |
3,547 | 5,869,013 | 2,996,859 | public Leilao insertLeilao(Leilao leilao) throws SQLException {
Connection conn = null;
String insert = "insert into Leilao (idleilao, atividade_idatividade, datainicio, datafim) " + "values " + "(nextval('seq_leilao'), " + leilao.getAtividade().getIdAtividade() + ", '" + leilao.getDataInicio() + "'... | public void run() {
StringBuffer xml;
String tabName;
Element guiElement;
setBold(monitor.getReading());
setBold(monitor.getReadingStatus());
monitor.getReadingStatus().setText(" Working");
HttpMethod method = null;
xml = new StringBuffer();
... | false |
3,548 | 922,716 | 169,201 | private static String getDocumentAt(String urlString) {
StringBuffer html_text = new StringBuffer();
try {
URL url = new URL(urlString);
URLConnection conn = url.openConnection();
BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream... | 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;
... | true |
3,549 | 14,196,272 | 2,439,668 | private synchronized File gzipTempFile(File tempFile) throws BlogunityException {
try {
File gzippedFile = new File(BlogunityManager.getSystemConfiguration().getTempDir(), tempFile.getName() + ".gz");
GZIPOutputStream zos = new GZIPOutputStream(new FileOutputStream(gzippedFile));
... | 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 |
3,550 | 6,533,214 | 17,515,284 | public void run() {
String s;
s = "";
try {
URL url = new URL("http://www.m-w.com/dictionary/" + word);
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String str;
while (((str = in.readLine()) != null) && (!sto... | public String readBaseLib() throws Exception {
if (_BASE_LIB_JS == null) {
StringBuffer js = new StringBuffer();
try {
URL url = AbstractRunner.class.getResource(_BASELIB_FILENAME);
if (url != null) {
InputStream is = url.openStream... | true |
3,551 | 22,608,103 | 3,217,210 | public static boolean copyFile(File sourceFile, File destFile) {
FileChannel srcChannel = null;
FileChannel dstChannel = null;
try {
srcChannel = new FileInputStream(sourceFile).getChannel();
dstChannel = new FileOutputStream(destFile).getChannel();
long p... | private boolean request(URI uri, Controller controller, String login, String password) {
SSLHttpClient client = new SSLHttpClient();
client.getCredentialsProvider().setCredentials(new AuthScope(uri.getHost(), uri.getPort()), new UsernamePasswordCredentials(login, password));
... | false |
3,552 | 23,439,557 | 2,711,577 | public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.out.println("arguments: sourcefile destfile");
System.exit(1);
}
FileChannel in = new FileInputStream(args[0]).getChannel(), out = new FileOutputStream(args[1]).getChannel();
... | private static void _checkConfigFile() throws Exception {
try {
String filePath = getUserManagerConfigPath() + "user_manager_config.properties";
boolean copy = false;
File from = new java.io.File(filePath);
if (!from.exists()) {
Properties prop... | true |
3,553 | 2,494,612 | 12,606,395 | private void update() throws IOException {
FileOutputStream out = new FileOutputStream(combined);
try {
File[] _files = listJavascript();
List<File> files = new ArrayList<File>(Arrays.asList(_files));
files.add(0, new File(jsdir.getAbsolute... | public static String SHA1(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md;
md = MessageDigest.getInstance("SHA-1");
byte[] sha1hash = new byte[40];
md.update(text.getBytes("iso-8859-1"), 0, text.length());
sha1hash = md.digest();
... | false |
3,554 | 1,035,597 | 460,972 | private Concept fetchDataNeeded(String conceptUri) {
if (cache.size() > MAX_CACHE) cache.clear();
if (cache.containsKey(conceptUri)) return this.cache.get(conceptUri);
try {
URL url = new URL(conceptUri);
HttpURLConnection connection = (HttpURLConnection) url.openConn... | public static void main(String[] args) throws MalformedURLException, IOException {
URL url = new URL("https://imo.im/");
URLConnection con = url.openConnection();
InputStream is = con.getInputStream();
ByteArrayOutputStream out = new ByteArrayOutputStream();
byte[] buffer = n... | false |
3,555 | 1,831,861 | 6,867,571 | private Document getXML(String artist) throws Exception {
Document doc = null;
URL url = new URL("http://" + disgogsUrl + "/artist/" + formatQuery(artist) + "?f=xml&api_key=" + apiKey[0]);
HttpURLConnection uc = (HttpURLConnection) url.openConnection();
uc.addRequestProperty("Accept-... | public void run() {
synchronized (stateLock) {
if (started) {
return;
} else {
started = true;
running = true;
}
}
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
BufferedRead... | false |
3,556 | 22,072,293 | 235,245 | @TestTargetNew(level = TestLevel.ADDITIONAL, notes = "", method = "SecureCacheResponse", args = { })
public void test_additional() throws Exception {
URL url = new URL("http://google.com");
ResponseCache.setDefault(new TestResponseCache());
HttpURLConnection httpCon = (HttpURLConnection... | public void convert(File src, File dest) throws IOException {
InputStream in = new BufferedInputStream(new FileInputStream(src));
DcmParser p = pfact.newDcmParser(in);
Dataset ds = fact.newDataset();
p.setDcmHandler(ds.getDcmHandler());
try {
FileFormat format = p... | false |
3,557 | 4,318,399 | 22,382,481 | private void unzipEntry(ZipFile zipfile, ZipEntry entry, File outputDir, BackUpInfoFileGroup fileGroup, LinkedList<String> restoreList) {
LinkedList<BackUpInfoFile> fileList = fileGroup.getFileList();
if (entry.isDirectory()) {
createDir(new File(outputDir, entry.getName()));
... | public boolean ReadFile() {
boolean ret = false;
FilenameFilter FileFilter = null;
File dir = new File(fDir);
String[] FeeFiles;
int Lines = 0;
BufferedReader FeeFile = null;
PreparedStatement DelSt = null, InsSt = null;
String Line = null, Term = null... | false |
3,558 | 7,682,647 | 19,262,311 | public static void copyFile(String oldPathFile, String newPathFile) {
try {
int bytesum = 0;
int byteread = 0;
File oldfile = new File(oldPathFile);
if (oldfile.exists()) {
InputStream inStream = new FileInputStream(oldPathFile);
... | public static String encrypt(String key) {
MessageDigest md5 = null;
try {
md5 = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
md5.update(key.getBytes());
byte hash[] = md5.digest();
Str... | false |
3,559 | 17,456,433 | 3,375,723 | public static boolean isSameHttpContent(final String url, final File localFile, UsernamePasswordCredentials creds) throws IOException {
if (localFile.isFile()) {
long localContentLength = localFile.length();
long localLastModified = localFile.lastModified() / 1000;
long c... | public void importarEmpresasAbertas(File pArquivoTXT, Andamento pAndamento) throws FileNotFoundException, SQLException {
int numeroDoRegistro = -1;
Scanner in = null;
Statement stmtLimpezaInicialDestino = conDestino.createStatement();
String sql = "TRUNCATE TABLE TMP_TB_CIA_ABERTA";
... | false |
3,560 | 9,860,858 | 15,353,022 | @Override
public boolean register(String username, String password) {
this.getLogger().info(DbUserServiceImpl.class, ">>>rigister " + username + "<<<");
try {
if (this.getDbServ().queryFeelerUser(username) != null) {
return false;
}
MessageDige... | private String calculateHash(String s) {
if (s == null) {
return null;
}
MessageDigest messageDigest;
try {
messageDigest = MessageDigest.getInstance("SHA");
} catch (NoSuchAlgorithmException e) {
logger.error("Could not find a message dige... | true |
3,561 | 10,871,260 | 23,021,618 | public static final String getUniqueId() {
String digest = "";
try {
MessageDigest md = MessageDigest.getInstance("MD5");
String timeVal = "" + (System.currentTimeMillis() + 1);
String localHost = "";
try {
localHost = InetAddress.getLo... | public boolean WriteFile(java.io.Serializable inObj, String fileName) throws Exception {
FileOutputStream out;
try {
SecretKey skey = null;
AlgorithmParameterSpec aps;
out = new FileOutputStream(fileName);
cipher = Cipher.getInstance(algorithm);
... | true |
3,562 | 17,724,878 | 8,639,730 | public byte[] getDigest(OMProcessingInstruction pi, String digestAlgorithm) throws OMException {
byte[] digest = new byte[0];
try {
MessageDigest md = MessageDigest.getInstance(digestAlgorithm);
md.update((byte) 0);
md.update((byte) 0);
md.update((byte... | public static String md5encrypt(String toEncrypt) {
if (toEncrypt == null) {
throw new IllegalArgumentException("null is not a valid password to encrypt");
}
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(toEncrypt.getBytes());
... | true |
3,563 | 3,331,971 | 10,816,804 | protected void onSubmit() {
try {
Connection conn = ((JdbcRequestCycle) getRequestCycle()).getConnection();
String sql = "insert into entry (author, accessibility) values(?,?)";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, userId);
... | public static String md5(String input) throws NoSuchAlgorithmException, UnsupportedEncodingException {
StringBuffer result = new StringBuffer();
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(input.getBytes("utf-8"));
byte[] digest = md.digest();
for (byte b :... | false |
3,564 | 906,241 | 20,183,892 | 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;
... | @Override
public String encryptString(String passphrase, String message) throws Exception {
MessageDigest md;
md = MessageDigest.getInstance("MD5");
md.update(passphrase.getBytes("UTF-8"));
byte digest[] = md.digest();
String digestString = base64encode(digest);
S... | false |
3,565 | 21,461,424 | 18,144,642 | public static final void copy(String source, String destination) {
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream(source);
fos = new FileOutputStream(destination);
java.nio.channels.FileChannel channelSrc = fis.get... | public static String crypt(String senha) {
String md5 = null;
MessageDigest md;
try {
md = MessageDigest.getInstance(CRYPT_ALGORITHM);
md.update(senha.getBytes());
Hex hex = new Hex();
md5 = new String(hex.encode(md.digest()));
} catch ... | false |
3,566 | 8,384,813 | 18,730,318 | public void testExplicitHeaders() throws Exception {
String headerString = "X-Foo=bar&X-Bar=baz%20foo";
HttpRequest expected = new HttpRequest(REQUEST_URL).addHeader("X-Foo", "bar").addHeader("X-Bar", "baz foo");
expect(pipeline.execute(expected)).andReturn(new HttpResponse(RESPONSE_BODY));
... | public boolean write(Node node, LSOutput output) throws LSException {
OutputStream out = output.getByteStream();
try {
if (out == null) {
String systemId = output.getSystemId();
try {
URL url = new URL(systemId);
URL... | false |
3,567 | 19,823,544 | 11,941,001 | @Override
public CelShadingModel loadModel(URL url, String skin) throws IOException, IncorrectFormatException, ParsingErrorException {
boolean baseURLWasNull = setBaseURLFromModelURL(url);
CelShadingModel model = loadModel(url.openStream(), skin);
if (baseURLWasNull) {
popBas... | private static void insertFiles(Connection con, File file) throws IOException {
BufferedReader bf = new BufferedReader(new FileReader(file));
String line = bf.readLine();
while (line != null) {
if (!line.startsWith(" ") && !line.startsWith("#")) {
try {
... | false |
3,568 | 8,688,357 | 13,521,323 | public void runDynusT() {
final String[] exeFiles = new String[] { "DynusT.exe", "DLL_ramp.dll", "Ramp_Meter_Fixed_CDLL.dll", "Ramp_Meter_Feedback_CDLL.dll", "Ramp_Meter_Feedback_FDLL.dll", "libifcoremd.dll", "libmmd.dll", "Ramp_Meter_Fixed_FDLL.dll", "libiomp5md.dll" };
final String[] modelFiles = ... | public static void copyFile(final String inFile, final String outFile) {
FileChannel in = null;
FileChannel out = null;
try {
in = new FileInputStream(inFile).getChannel();
out = new FileOutputStream(outFile).getChannel();
in.transferTo(0, in.size(), out);... | true |
3,569 | 1,856,551 | 15,669,668 | public InputStream open() {
try {
if ("file".equals(url.getProtocol())) {
if (new File(url.toURI()).exists()) {
inputStream = url.openStream();
}
} else {
con = url.openConnection();
if (con instanceo... | 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);
... | false |
3,570 | 12,800,568 | 4,260,650 | public void exportFile() {
String expfolder = PropertyHandler.getInstance().getProperty(PropertyHandler.KINDLE_EXPORT_FOLDER_KEY);
File out = new File(expfolder + File.separator + previewInfo.getTitle() + ".prc");
File f = new File(absPath);
try {
FileOutputStream fout = ... | public void copyFile(File sourceFile, File destFile) throws IOException {
if (!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
Closer c = new Closer();
try {
source = c.register(new Fi... | true |
3,571 | 19,322,906 | 13,431,537 | @Test
public void test_baseMaterialsForTypeID_NonExistingID() throws Exception {
URL url = new URL(baseUrl + "/baseMaterialsForTypeID/1234567890");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestPr... | @Override
public int updateStatus(UserInfo userInfo, String status, String picturePath) {
HttpClient client = new DefaultHttpClient();
HttpPost post = new HttpPost(SnsConstant.SOHU_UPDATE_STATUS_URL);
List<NameValuePair> parameters = new ArrayList<NameValuePair>();
parameters.add... | false |
3,572 | 19,979,783 | 16,458,721 | public static void writeEntry(File file, File input) throws PersistenceException {
try {
File temporaryFile = File.createTempFile("pmMDA_zargo", ARGOUML_EXT);
temporaryFile.deleteOnExit();
ZipOutputStream output = new ZipOutputStream(new FileOutputStream(temporaryFile));
... | public String stringOfUrl(String addr) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
URL url = new URL(addr);
IOUtils.copy(url.openStream(), output);
return output.toString();
}
| true |
3,573 | 16,568,044 | 8,701,067 | public void setContentAsStream(final InputStream input) throws IOException {
ByteArrayOutputStream output = new ByteArrayOutputStream();
try {
IOUtils.copy(input, output);
} finally {
output.close();
}
this.content = output.toByteArray();
}
| public void markAsCachedHelper(Item item, Date from, Date to, Map<String, Boolean> properties) {
if (properties.size() == 0) {
return;
}
Connection conn = null;
Iterable<Integer> props = representer.getInternalReps(properties.keySet());
Integer hostIndex = represe... | false |
3,574 | 18,194,344 | 10,871,260 | public void setPassword(String plaintext) throws java.security.NoSuchAlgorithmException {
StringBuffer encrypted = new StringBuffer();
java.security.MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
digest.update(plaintext.getBytes());
byte[] digestArray = digest... | public static final String getUniqueId() {
String digest = "";
try {
MessageDigest md = MessageDigest.getInstance("MD5");
String timeVal = "" + (System.currentTimeMillis() + 1);
String localHost = "";
try {
localHost = InetAddress.getLo... | true |
3,575 | 9,639,432 | 555,865 | private static String deviceIdFromCombined_Device_ID(Context context) {
StringBuilder builder = new StringBuilder();
builder.append(deviceIdFromIMEI(context));
builder.append(deviceIdFromPseudo_Unique_Id());
builder.append(deviceIdFromAndroidId(context));
builder.append(devic... | public void testServletTesterClient() throws Exception {
String base_url = tester.createSocketConnector(true);
URL url = new URL(base_url + "/context/hello/info");
String result = IO.toString(url.openStream());
assertEquals("<h1>Hello Servlet</h1>", result);
}
| false |
3,576 | 3,609,806 | 15,311,521 | private static String getData(String myurl) throws Exception {
System.out.println("getdata");
URL url = new URL(myurl);
uc = (HttpURLConnection) url.openConnection();
br = new BufferedReader(new InputStreamReader(uc.getInputStream()));
String temp = "", k = "";
while ... | public String buscaCDA() {
Properties prop = new CargaProperties().Carga();
URL url;
BufferedReader in;
String inputLine;
String miLinea = null;
try {
url = new URL(prop.getProperty("CDA"));
in = new BufferedReader(new InputStreamReader(url.ope... | true |
3,577 | 18,371,114 | 14,840,321 | public static void copy(final File source, final File dest) throws IOException {
FileChannel in = null;
FileChannel out = null;
try {
in = new FileInputStream(source).getChannel();
out = new FileOutputStream(dest).getChannel();
long size = in.size();
... | public static void copy(FileInputStream source, FileOutputStream dest) throws IOException {
FileChannel in = null, out = null;
try {
in = source.getChannel();
out = dest.getChannel();
long size = in.size();
MappedByteBuffer buf = in.map(FileChannel.Map... | true |
3,578 | 17,613,722 | 9,594,116 | public void go() throws FBConnectionException, FBErrorException, IOException {
clearError();
if (rg == null) {
error = true;
errorcode = -102;
errortext = "No RootGalleryTree was defined";
return;
}
URL url = new URL(getHost() + getPath... | public static String hash(String arg) throws NoSuchAlgorithmException {
String input = arg;
String output;
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(input.getBytes());
output = Hex.encodeHexString(md.digest());
return output;
}
| false |
3,579 | 386,013 | 254,039 | 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;
... | protected void doDownload(S3Bucket bucket, S3Object s3object) throws Exception {
String key = s3object.getKey();
key = trimPrefix(key);
String[] path = key.split("/");
String fileName = path[path.length - 1];
String dirPath = "";
for (int i = 0; i < path.length - 1; i... | false |
3,580 | 657,801 | 4,293,344 | void copyFile(String from, String to) throws IOException {
File destFile = new File(to);
if (!destFile.exists()) {
destFile.createNewFile();
}
FileChannel source = null;
FileChannel destination = null;
try {
... | public ResourceBundle getResources() {
if (resources == null) {
String lang = userProps.getProperty("language");
lang = "en";
try {
URL myurl = getResource("Resources_" + lang.trim() + ".properties");
InputStream in = myurl.openStream();
... | false |
3,581 | 5,824,704 | 9,135,964 | @Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, final HttpServletResponse response) throws Exception {
final String id = request.getParameter("id");
if (id == null) {
response.sendError(HttpServletResponse.SC_BAD_REQUEST);
return null;
... | private BufferedReader getReader(final String fileUrl) throws IOException {
InputStreamReader reader;
try {
reader = new FileReader(fileUrl);
} catch (FileNotFoundException e) {
URL url = new URL(fileUrl);
reader = new InputStreamReader(url.openStream());
... | false |
3,582 | 3,516,106 | 16,012,363 | 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 void main(String[] args) throws IOException {
String uri = "hdfs://localhost:8020/user/leeing/maxtemp/sample.txt";
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(uri), conf);
InputStream in = null;
try {
in = fs.o... | false |
3,583 | 17,530,413 | 11,572,565 | protected void serveStaticContent(HttpServletRequest request, HttpServletResponse response, String pathInfo) throws ServletException {
InputStream is = servletConfig.getServletContext().getResourceAsStream(pathInfo);
if (is == null) {
throw new ServletException("Static resource " + pathI... | public static final boolean copy(File source, File target, boolean overwrite) {
if (!overwrite && target.exists()) {
LOGGER.error("Target file exist and it not permitted to overwrite it !");
return false;
}
FileChannel in = null;
FileChannel out = null;
... | true |
3,584 | 13,106,834 | 3,024,984 | public void copyFilesIntoProject(HashMap<String, String> files) {
Set<String> filenames = files.keySet();
for (String key : filenames) {
String realPath = files.get(key);
if (key.equals("fw4ex.xml")) {
try {
FileReader in = new FileReader(n... | @Test
public void testCopy_readerToOutputStream() throws Exception {
InputStream in = new ByteArrayInputStream(inData);
in = new YellOnCloseInputStreamTest(in);
Reader reader = new InputStreamReader(in, "US-ASCII");
ByteArrayOutputStream baout = new ByteArrayOutputStream();
... | true |
3,585 | 4,192,187 | 5,893,532 | public void copyTo(Bean bean, OutputStream out, int offset, int length) throws Exception {
BeanInfo beanInfo = getBeanInfo(bean.getClass());
validate(bean, beanInfo, "copyTo");
if (blobCache != null && length < MAX_BLOB_CACHE_LENGHT) {
byte[] bytes = null;
synchronize... | public static void upload(FTPDetails ftpDetails) {
FTPClient ftp = new FTPClient();
try {
String host = ftpDetails.getHost();
logger.info("Connecting to ftp host: " + host);
ftp.connect(host);
logger.info("Received reply from ftp :" + ftp.getReplyStrin... | true |
3,586 | 21,195,765 | 6,222,230 | private void writeFile(FileInputStream inFile, FileOutputStream outFile) throws IOException {
byte[] buf = new byte[2048];
int read;
while ((read = inFile.read(buf)) > 0) outFile.write(buf, 0, read);
inFile.close();
}
| public static String loadWebsiteHtmlCode(String url, String useragent) {
HttpClient httpClient = new DefaultHttpClient();
HttpGet getMethod = new HttpGet(url);
String htmlCode = "";
if (useragent != null) {
getMethod.setHeader("user-agent", useragent);
}
t... | false |
3,587 | 1,699,618 | 17,907,353 | public static void copyURLToFile(URL source, File destination) throws IOException {
if (destination.getParentFile() != null && !destination.getParentFile().exists()) {
destination.getParentFile().mkdirs();
}
if (destination.exists() && !destination.canWrite()) {
Strin... | public static void resourceToFile(final String resource, final String filePath) throws IOException {
log.debug("Classloader is " + IOCopyUtils.class.getClassLoader());
InputStream in = IOCopyUtils.class.getResourceAsStream(resource);
if (in == null) {
log.warn("Resource not '" + ... | true |
3,588 | 12,328,424 | 3,584,277 | private 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 int copyFile(File src, File dest) throws IOException {
FileChannel in = null, out = null;
try {
in = new FileInputStream(src).getChannel();
out = new FileOutputStream(dest).getChannel();
in.transferTo(0, in.size(), out);
} finally {
... | true |
3,589 | 4,871,307 | 1,008,331 | private boolean authenticateWithServer(String user, String password) {
Object o;
String response;
byte[] dataKey;
try {
o = objectIn.readObject();
if (o instanceof String) {
response = (String) o;
Debug.netMsg("Connected to JFri... | public long copyFileWithPaths(String userBaseDir, String sourcePath, String destinPath) throws Exception {
if (userBaseDir.endsWith(sep)) {
userBaseDir = userBaseDir.substring(0, userBaseDir.length() - sep.length());
}
String file1FullPath = new String();
if (sourcePath.s... | false |
3,590 | 129,098 | 9,327,524 | 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 {
... | @Test
public void test01_ok_failed_500() throws Exception {
DefaultHttpClient client = new DefaultHttpClient();
try {
HttpPost post = new HttpPost(chartURL);
HttpResponse response = client.execute(post);
assertEquals("failed code for ", 500, response.getStatus... | false |
3,591 | 15,958,994 | 14,855,960 | public String loadURLString(java.net.URL url) {
try {
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
StringBuffer buf = new StringBuffer();
String s = "";
while (br.ready() && s != null) {
s = br.readLine();
... | private static List<InputMethodDescriptor> loadIMDescriptors() {
String nm = SERVICES + InputMethodDescriptor.class.getName();
Enumeration<URL> en;
LinkedList<InputMethodDescriptor> imdList = new LinkedList<InputMethodDescriptor>();
NativeIM nativeIM = ContextStorage.getNativeIM();
... | true |
3,592 | 22,135,200 | 427,727 | public void testCodingCompletedFromFile() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
WritableByteChannel channel = newChannel(baos);
HttpParams params = new BasicHttpParams();
SessionOutputBuffer outbuf = new SessionOutputBufferImpl(1024, 128, params... | public BufferedWriter createOutputStream(String inFile, String outFile) throws IOException {
int k_blockSize = 1024;
int byteCount;
char[] buf = new char[k_blockSize];
File ofp = new File(outFile);
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(ofp));
... | true |
3,593 | 9,597,888 | 23,512,890 | private void javaToHtml(File source, File destination) throws IOException {
Reader reader = new FileReader(source);
Writer writer = new FileWriter(destination);
JavaUtils.writeJava(reader, writer);
writer.flush();
writer.close();
}
| private boolean write(File file) {
String filename = file.getPath();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
PrintStream out = new PrintStream(byteArrayOutputStream);
try {
StringBuffer xml = null;
if (MainFrame.getInstance()... | true |
3,594 | 11,403,723 | 6,128,265 | 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);
... | private void makeDailyBackup() throws CacheOperationException, ConfigurationException {
final int MAX_DAILY_BACKUPS = 5;
File cacheFolder = getBackupFolder();
cacheLog.debug("Making a daily backup of current Beehive archive...");
try {
File oldestDaily = new File(DAILY_BA... | true |
3,595 | 19,886,621 | 5,260,867 | private void doPOST(HttpURLConnection connection, InputStream inputXML) throws MessageServiceException {
try {
OutputStream requestStream = new BufferedOutputStream(connection.getOutputStream());
IOUtils.copyAndClose(inputXML, requestStream);
connection.connect();
... | public BufferedWriter createWriter(File outfile, String encoding) throws UnsupportedEncodingException, IOException {
int k_blockSize = 1024;
int byteCount;
char[] buf = new char[k_blockSize];
ZipOutputStream zos = new ZipOutputStream(new FileOutputStream(outfile));
zos.setMet... | true |
3,596 | 19,172,809 | 19,199,682 | public static Document parseDocument(Object toParse, boolean isFile, List<ErrorMessage> errorMessages) {
Document document = null;
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
docBuilderFactory.setValidating(true);
docBuil... | public SimplePropertiesMessageRepository() {
properties = new Properties();
try {
URL url = SimplePropertiesIconRepository.class.getResource(PROPERTIES_FILE_NAME);
properties.load(url.openStream());
} catch (Exception e) {
throw new Error("Messages file no... | false |
3,597 | 10,689,659 | 3,024,981 | 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... | @Test
public void testCopy_inputStreamToWriter_Encoding_nullIn() throws Exception {
ByteArrayOutputStream baout = new ByteArrayOutputStream();
OutputStream out = new YellOnFlushAndCloseOutputStreamTest(baout, true, true);
Writer writer = new OutputStreamWriter(baout, "US-ASCII");
... | true |
3,598 | 15,821,341 | 16,164,368 | public void update() {
try {
String passwordMD5 = new String();
if (this.password != null && this.password.length() > 0) {
MessageDigest md = MessageDigest.getInstance("md5");
md.update(this.password.getBytes());
byte[] digest = md.dige... | public static String getHashedPassword(String password) {
try {
MessageDigest digest = MessageDigest.getInstance("MD5");
digest.update(password.getBytes());
BigInteger hashedInt = new BigInteger(1, digest.digest());
return String.format("%1$032X", hashedInt);
... | true |
3,599 | 4,798,331 | 22,899,738 | public static String SHA256(String source) {
logger.info(source);
String result = null;
try {
MessageDigest digest = MessageDigest.getInstance("SHA-256");
digest.update(source.getBytes());
byte[] bytes = digest.digest();
result = EncodeUtils.he... | public synchronized String encrypt(String password) throws NoSuchAlgorithmException, UnsupportedEncodingException {
MessageDigest md = null;
md = MessageDigest.getInstance("SHA-256");
md.update(password.getBytes("UTF-8"));
byte raw[] = md.digest();
String hash = (new BASE64En... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.