label class label 2
classes | source_code stringlengths 398 72.9k |
|---|---|
11 | Code Sample 1:
public boolean import_status(String filename) { int pieceId; int i, j, col, row; int rotation; int number; boolean byurl = false; e2piece temppiece; String lineread; StringTokenizer tok; BufferedReader entree; try { if (byurl == true) { URL url = new URL(baseURL, filename); InputStream in = url.openStrea... |
11 | Code Sample 1:
public static byte[] SHA1(String... strings) { try { MessageDigest digest = MessageDigest.getInstance("SHA1"); digest.reset(); for (String string : strings) { digest.update(string.getBytes("UTF-8")); } return digest.digest(); } catch (NoSuchAlgorithmException e) { throw new RuntimeException(e.toString(),... |
00 | Code Sample 1:
public static String hashMD5(String passw) { String passwHash = ""; try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(passw.getBytes()); byte[] result = md.digest(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < result.length; i++) { String tmpStr = "0" + Integer.toHexStrin... |
00 | Code Sample 1:
public void resumereceive(HttpServletRequest req, HttpServletResponse resp, SessionCommand command) { setHeader(resp); try { logger.debug("ResRec: Resume a 'receive' session with session id " + command.getSession() + " this client already received " + command.getLen() + " bytes"); File tempFile = new Fil... |
00 | Code Sample 1:
public static Image loadImage(URL url) throws IOException { BufferedInputStream in = new BufferedInputStream(url.openStream()); try { return getLoader(url.getFile()).loadImage(in); } finally { in.close(); } }
Code Sample 2:
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE... |
11 | Code Sample 1:
public static String getTextFromPart(Part part) { try { if (part != null && part.getBody() != null) { InputStream in = part.getBody().getInputStream(); String mimeType = part.getMimeType(); if (mimeType != null && MimeUtility.mimeTypeMatches(mimeType, "text/*")) { ByteArrayOutputStream out = new ByteArra... |
11 | Code Sample 1:
protected static String getFileContentAsString(URL url, String encoding) throws IOException { InputStream input = null; StringWriter sw = new StringWriter(); try { System.out.println("Free mem :" + Runtime.getRuntime().freeMemory()); input = url.openStream(); IOUtils.copy(input, sw, encoding); System.out... |
11 | Code Sample 1:
public static void copy(File source, File dest) throws BuildException { dest = new File(dest, source.getName()); if (source.isFile()) { byte[] buffer = new byte[4096]; FileInputStream fin = null; FileOutputStream fout = null; try { fin = new FileInputStream(source); fout = new FileOutputStream(dest); int... |
11 | Code Sample 1:
public void testCreateNewXMLFile() throws InvalidNodeTypeDefException, ParseException, Exception { JCRNodeSource emptySource = loadTestSource(); assertEquals(false, emptySource.exists()); OutputStream sourceOut = emptySource.getOutputStream(); assertNotNull(sourceOut); InputStream contentIn = getClass().... |
11 | Code Sample 1:
public void objectParserAssesmentItem(int file, int currentquestion, Resource resTemp) { NodeList nl = null; Node n = null; NamedNodeMap nnp = null; Node nsrc = null; URL url = null; String sFilename = ""; String sNewPath = ""; int indexLastSeparator; String sOldPath = ""; try { if (file == 1) { nl = doc... |
00 | Code Sample 1:
private void login() throws LoginException { log.info("# iモード.netにログイン"); try { this.httpClient.getCookieStore().clear(); HttpPost post = new HttpPost(LoginUrl); List<NameValuePair> formparams = new ArrayList<NameValuePair>(); formparams.add(new BasicNameValuePair("HIDEURL", "?WM_AK=https%3a%2f%2fimode.n... |
00 | Code Sample 1:
public VersionInfo getVersionInfo(String url) { try { XmlContentHandler handler = new XmlContentHandler(); XMLReader myReader = XMLReaderFactory.createXMLReader(); myReader.setContentHandler(handler); myReader.parse(new InputSource(new URL(url).openStream())); return handler.getVersionInfo(); } catch (SA... |
11 | Code Sample 1:
public void testCreateNewXMLFile() throws InvalidNodeTypeDefException, ParseException, Exception { JCRNodeSource emptySource = loadTestSource(); assertEquals(false, emptySource.exists()); OutputStream sourceOut = emptySource.getOutputStream(); assertNotNull(sourceOut); InputStream contentIn = getClass().... |
00 | Code Sample 1:
protected InputStream makeRequestAndGetJSONData(String url) throws URISyntaxException, ClientProtocolException, IOException { DefaultHttpClient httpClient = new DefaultHttpClient(); URI uri; InputStream data = null; uri = new URI(url); HttpGet method = new HttpGet(uri); HttpResponse response = httpClient... |
11 | Code Sample 1:
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 ("SHA".equalsIgnoreCase(algorithm) || "SSHA"... |
11 | Code Sample 1:
public void migrateTo(String newExt) throws IOException { DigitalObject input = new DigitalObject.Builder(Content.byReference(new File(AllJavaSEServiceTestsuite.TEST_FILE_LOCATION + "PlanetsLogo.png").toURI().toURL())).build(); System.out.println("Input: " + input); FormatRegistry format = FormatRegistry... |
11 | Code Sample 1:
public static int executeUpdate(EOAdaptorChannel channel, String sql, boolean autoCommit) throws SQLException { int rowsUpdated; boolean wasOpen = channel.isOpen(); if (!wasOpen) { channel.openChannel(); } Connection conn = ((JDBCContext) channel.adaptorContext()).connection(); try { Statement stmt = con... |
00 | Code Sample 1:
public 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(); destination = new FileOutputStream(destFile).getChannel()... |
00 | Code Sample 1:
public ResourceMigrator getCompletedResourceMigrator() { return new ResourceMigrator() { public void migrate(InputMetadata meta, InputStream inputStream, OutputCreator outputCreator) throws IOException, ResourceMigrationException { OutputStream outputStream = outputCreator.createOutputStream(); IOUtils.c... |
00 | Code Sample 1:
public static boolean downFile(String url, String username, String password, String remotePath, Date DBLastestDate, String localPath) { File dFile = new File(localPath); if (!dFile.exists()) { dFile.mkdir(); } boolean success = false; FTPClient ftp = new FTPClient(); ftp.setConnectTimeout(connectTimeout)... |
00 | Code Sample 1:
private static Map<String, File> loadServiceCache() { ArrayList<String> preferredOrder = new ArrayList<String>(); HashMap<String, File> serviceFileMapping = new HashMap<String, File>(); File file = new File(IsqlToolkit.getBaseDirectory(), CACHE_FILE); if (!file.exists()) { return serviceFileMapping; } if... |
11 | Code Sample 1:
public static void copyURLToFile(URL source, File destination) throws IOException { InputStream input = source.openStream(); try { FileOutputStream output = openOutputStream(destination); try { IOUtils.copy(input, output); } finally { IOUtils.closeQuietly(output); } } finally { IOUtils.closeQuietly(input... |
00 | Code Sample 1:
public void saveUploadFiles(List uploadFiles) throws SQLException { Connection conn = AppLayerDatabase.getInstance().getPooledConnection(); try { conn.setAutoCommit(false); Statement s = conn.createStatement(); s.executeUpdate("DELETE FROM UPLOADFILES"); s.close(); s = null; PreparedStatement ps = conn.p... |
00 | Code Sample 1:
public boolean backupLastAuditSchema(File lastAuditSchema) { boolean isBkupFileOK = false; String writeTimestamp = DateFormatUtils.format(new java.util.Date(), configFile.getTimestampPattern()); File target = new File(configFile.getAuditSchemaFileDir() + File.separator + configFile.getAuditSchemaFileName... |
11 | Code Sample 1:
public static void copy(File source, File dest) throws BuildException { dest = new File(dest, source.getName()); if (source.isFile()) { byte[] buffer = new byte[4096]; FileInputStream fin = null; FileOutputStream fout = null; try { fin = new FileInputStream(source); fout = new FileOutputStream(dest); int... |
00 | Code Sample 1:
private void createTree(DefaultMutableTreeNode top) throws MalformedURLException, ParserConfigurationException, SAXException, IOException { InputStream stream; URL url = new URL(SHIPS_URL + view.getBaseurl()); try { stream = url.openStream(); } catch (Exception e) { stream = getClass().getResourceAsStrea... |
11 | Code Sample 1:
public static void copyFile5(File srcFile, File destFile) throws IOException { InputStream in = new FileInputStream(srcFile); OutputStream out = new FileOutputStream(destFile); IOUtils.copyLarge(in, out); in.close(); out.close(); }
Code Sample 2:
public static void main(String[] args) throws Exception {... |
11 | Code Sample 1:
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.ENCODE); out = new java.io.Buffer... |
00 | Code Sample 1:
public static String hash(String string, String algorithm, String encoding) throws UnsupportedEncodingException { try { MessageDigest digest = MessageDigest.getInstance(algorithm); digest.update(string.getBytes(encoding)); byte[] encodedPassword = digest.digest(); return new BigInteger(1, encodedPassword... |
11 | Code Sample 1:
public static void copy(File sourceFile, File destinationFile) throws IOException { FileChannel sourceChannel = new FileInputStream(sourceFile).getChannel(); FileChannel destinationChannel = new FileOutputStream(destinationFile).getChannel(); destinationChannel.transferFrom(sourceChannel, 0, sourceChanne... |
00 | Code Sample 1:
public void go() throws FBConnectionException, FBErrorException, IOException { clearError(); results = new LoginResults(); URL url = new URL(getHost() + getPath()); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); conn.setRequestProperty("X-FB-User", getUser()); conn.setRequestProperty(... |
00 | Code Sample 1:
public static void main(String[] args) throws IOException { ServerSocket serverSocket = null; try { serverSocket = new ServerSocket(4444); } catch (IOException e) { System.err.println("Could not listen on port: 4444."); System.exit(1); } Socket clientSocket = null; try { clientSocket = serverSocket.accep... |
11 | Code Sample 1:
private void pack() { String szImageDir = m_szBasePath + "Images"; File fImageDir = new File(szImageDir); fImageDir.mkdirs(); String ljIcon = System.getProperty("user.home"); ljIcon += System.getProperty("file.separator") + "MochaJournal" + System.getProperty("file.separator") + m_szUsername + System.get... |
00 | Code Sample 1:
public static String hashStringMD5(String string) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(string.getBytes()); byte byteData[] = md.digest(); StringBuffer sb = new StringBuffer(); for (int i = 0; i < byteData.length; i++) { sb.append(Integer.toStrin... |
00 | Code Sample 1:
public Object send(URL url, Object params) throws Exception { params = processRequest(params); String response = ""; BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); response += in.readLine(); while (response != null) response += in.readLine(); in.close(); return processRe... |
00 | Code Sample 1:
public static void downloadFile(String url, String filePath) throws IOException { BufferedInputStream inputStream = new BufferedInputStream(new URL(url).openStream()); BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(filePath)); try { int i = 0; while ((i = inputStream.read()) != ... |
00 | Code Sample 1:
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.isFile()) { try { FileChannel inChannel = new FileInputStream(file).getChannel(); FileCh... |
11 | Code Sample 1:
public boolean copier(String source, String nomFichierSource, java.io.File destination) { boolean resultat = false; OutputStream tmpOut; try { tmpOut = new BufferedOutputStream(new FileOutputStream(nomFichierSource + "001.tmp")); InputStream is = getClass().getResourceAsStream(source + nomFichierSource);... |
00 | Code Sample 1:
public String getLastReleaseVersion() throws TransferException { try { URL url = new URL("http://jtbdivelogbook.sourceforge.net/version.properties"); URLConnection urlConn = url.openConnection(); urlConn.setDoInput(true); urlConn.setUseCaches(false); urlConn.setReadTimeout(20000); urlConn.setConnectTimeo... |
00 | Code Sample 1:
private String unJar(String jarPath, String jarEntry) { String path; if (jarPath.lastIndexOf("lib/") >= 0) path = jarPath.substring(0, jarPath.lastIndexOf("lib/")); else path = jarPath.substring(0, jarPath.lastIndexOf("/")); String relPath = jarEntry.substring(0, jarEntry.lastIndexOf("/")); try { new Fil... |
00 | Code Sample 1:
public static void main(String[] args) { boolean rotateLeft = false; boolean rotateRight = false; boolean exclude = false; boolean reset = false; float quality = 0f; int thumbArea = 12000; for (int i = 0; i < args.length; i++) { if (args[i].equals("-rotl")) rotateLeft = true; else if (args[i].equals("-ro... |
00 | Code Sample 1:
@Override public int updateStatus(UserInfo userInfo, String status) throws Exception { OAuthConsumer consumer = SnsConstant.getOAuthConsumer(SnsConstant.SOHU); consumer.setTokenWithSecret(userInfo.getAccessToken(), userInfo.getAccessSecret()); try { URL url = new URL(SnsConstant.SOHU_UPDATE_STATUS_URL); ... |
00 | Code Sample 1:
@Test public final void testImportODS() throws Exception { URL url = ODSTableImporterTest.class.getResource("/Messages.ods"); InputStream in = url.openStream(); ODSTableImporter b = new ODSTableImporter(); b.importODS(in, null); assertMessagesOds(b); }
Code Sample 2:
public void convert(File src, File d... |
11 | Code Sample 1:
public void run() { GZIPInputStream gzipInputStream = null; try { gzipInputStream = new GZIPInputStream(pipedInputStream); IOUtils.copy(gzipInputStream, outputStream); } catch (Throwable t) { ungzipThreadThrowableList.add(t); } finally { IOUtils.closeQuietly(gzipInputStream); IOUtils.closeQuietly(pipedIn... |
00 | Code Sample 1:
public static String getHash(String key) { try { MessageDigest digest = MessageDigest.getInstance("MD5"); digest.update(key.getBytes()); return new BigInteger(digest.digest()).toString(16); } catch (NoSuchAlgorithmException e) { return key; } }
Code Sample 2:
private String fetchContent() throws IOExcep... |
00 | Code Sample 1:
private static boolean tryExpandGorillaHome(File f) throws GorillaHomeException { if (f.exists()) { if (!f.isDirectory() || !f.canWrite()) { return false; } } else { boolean dirOK = f.mkdirs(); } if (f.exists() && f.isDirectory() && f.canWrite()) { java.net.URL url = GorillaHome.class.getResource("/resou... |
00 | Code Sample 1:
private String mkSid() { String temp = toString(); MessageDigest messagedigest = null; try { messagedigest = MessageDigest.getInstance("SHA"); } catch (NoSuchAlgorithmException e) { e.printStackTrace(); return null; } messagedigest.update(temp.getBytes()); byte digest[] = messagedigest.digest(); String c... |
11 | Code Sample 1:
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.getNewsFeedUrl(); } else if (searchWeb) { HttpU... |
11 | Code Sample 1:
private static void copy(String fromFileName, String toFileName) throws IOException { File fromFile = new File(fromFileName); File toFile = new File(toFileName); if (!fromFile.exists()) throw new IOException("FileCopy: " + "no such source file: " + fromFileName); if (!fromFile.isFile()) throw new IOExcep... |
00 | Code Sample 1:
public List tree(String cat, int branch) { Pattern p = Pattern.compile("<a href=\"javascript:checkBranch\\(([0-9]+), 'true'\\)\">([^<]*)</a>"); Matcher m; List res = new ArrayList(); URL url; HttpURLConnection conn; System.out.println(); try { url = new URL("http://cri-srv-ade.insa-toulouse.fr:8080/ade/s... |
11 | Code Sample 1:
final void saveProject(Project project, final File file) { if (projectsList.contains(project)) { if (project.isDirty() || !file.getParentFile().equals(workspaceDirectory)) { try { if (!file.exists()) { if (!file.createNewFile()) throw new IOException("cannot create file " + file.getAbsolutePath()); } Fil... |
00 | Code Sample 1:
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]) { source[i] = source[i + 1]; source[i + 1] = temp; go = true; } } } }
Code Sample 2... |
11 | Code Sample 1:
public static void copyToFileAndCloseStreams(InputStream istr, File destFile) throws IOException { OutputStream ostr = null; try { ostr = new FileOutputStream(destFile); IOUtils.copy(istr, ostr); } finally { if (ostr != null) ostr.close(); if (istr != null) istr.close(); } }
Code Sample 2:
private stati... |
11 | Code Sample 1:
private static void zip(ZipArchiveOutputStream zos, File efile, String base) throws IOException { if (efile.isDirectory()) { File[] lf = efile.listFiles(); base = base + File.separator + efile.getName(); for (File file : lf) { zip(zos, file, base); } } else { ZipArchiveEntry entry = new ZipArchiveEntry(e... |
00 | Code Sample 1:
@Override public String getLatestApplicationVersion() { String latestVersion = null; String latestVersionInfoURL = "http://movie-browser.googlecode.com/svn/site/latest"; LOGGER.info("Checking latest version info from: " + latestVersionInfoURL); BufferedReader in = null; try { LOGGER.info("Fetcing latest ... |
11 | Code Sample 1:
public static int[] bubbleSortOtimizado(int... a) { boolean swapped; int n = a.length - 2; do { swapped = false; for (int i = 0; i <= n; i++) { if (a[i] > a[i + 1]) { int tmp = a[i]; a[i] = a[i + 1]; a[i + 1] = tmp; swapped = true; } } n = n - 1; } while (swapped); return a; }
Code Sample 2:
void sort(i... |
00 | Code Sample 1:
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 { in.close(); } catch (IOException ignore) { } } } }
Code Sample 2:
public String... |
00 | Code Sample 1:
public String MD5(String text) throws NoSuchAlgorithmException, UnsupportedEncodingException { MessageDigest md; md = MessageDigest.getInstance("MD5"); byte[] md5hash = new byte[32]; md.update(text.getBytes("iso-8859-1"), 0, text.length()); md5hash = md.digest(); return convertToHex(md5hash); }
Code Sam... |
00 | Code Sample 1:
private OSD downloadList() throws IOException, IllegalStateException, ParseException, URISyntaxException { OSD osd = null; HttpClient client = new DefaultHttpClient(); HttpGet getMethod = new HttpGet(new URI(listUri)); try { HttpResponse response = client.execute(getMethod); if (response.getStatusLine().... |
00 | Code Sample 1:
public static String encrypt(String text) { MessageDigest md = null; try { md = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException ex) { throw new WebDocRuntimeException(ex); } md.update(text.getBytes()); BigInteger hash = new BigInteger(1, md.digest()); return hash.toString(HEX); }
Cod... |
11 | Code Sample 1:
private void copyJdbcDriverToWL(final WLPropertyPage page) { final File url = new File(page.getDomainDirectory()); final File lib = new File(url, "lib"); final File mysqlLibrary = new File(lib, NexOpenUIActivator.getDefault().getMySQLDriver()); if (!mysqlLibrary.exists()) { InputStream driver = null; Fil... |
00 | Code Sample 1:
@Override public Response executeGet(String url) throws IOException { if (logger.isLoggable(INFO)) logger.info("Making a GET request to " + url); HttpURLConnection httpUrlConnection = null; InputStream inputStream = null; try { httpUrlConnection = openConnection(new URL(url)); httpUrlConnection.setReadTi... |
00 | Code Sample 1:
public Mappings read() { Mappings result = null; InputStream stream = null; try { XMLParser parser = new XMLParser(); stream = url.openStream(); result = parser.parse(stream); } catch (Throwable e) { log.error("Error in loading dozer mapping file url: [" + url + "] : " + e); MappingUtils.throwMappingExce... |
11 | Code Sample 1:
public String getData() throws ValueFormatException, RepositoryException, IOException { InputStream is = getStream(); StringWriter sw = new StringWriter(); IOUtils.copy(is, sw, "UTF-8"); IOUtils.closeQuietly(is); return sw.toString(); }
Code Sample 2:
public void guardarCantidad() { try { String can = S... |
11 | Code Sample 1:
public static void copyFile(final File in, final File out) throws IOException { final FileChannel inChannel = new FileInputStream(in).getChannel(); final FileChannel outChannel = new FileOutputStream(out).getChannel(); try { inChannel.transferTo(0, inChannel.size(), outChannel); } catch (IOException e) {... |
11 | Code Sample 1:
public synchronized void checkout() throws SQLException, InterruptedException { Connection con = this.session.open(); con.setAutoCommit(false); String sql_stmt = DB2SQLStatements.shopping_cart_getAll(this.customer_id); Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONC... |
11 | Code Sample 1:
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String contentId = req.getParameter(CONTENT_ID); String contentType = req.getParameter(CONTENT_TYPE); if (contentId == null || contentType == null) { resp.sendError(HttpServletResponse.... |
11 | Code Sample 1:
public String loadFileContent(final String _resourceURI) { final Lock readLock = this.fileLock.readLock(); final Lock writeLock = this.fileLock.writeLock(); boolean hasReadLock = false; boolean hasWriteLock = false; try { readLock.lock(); hasReadLock = true; if (!this.cachedResources.containsKey(_resourc... |
00 | Code Sample 1:
public void appendFetch(IProgress progress, PrintWriter pw, String list, int from, int to) throws IOException { progress.start(); try { File storage = new File(cacheDirectory.getValue(), "mboxes"); storage.mkdirs(); File mbox = new File(storage, list + "-" + from + "-" + to + ".mbox"); if (mbox.exists())... |
11 | Code Sample 1:
public static String httpGet(URL url) throws Exception { URLConnection connection = url.openConnection(); BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); StringBuffer content = new StringBuffer(); String line = null; while ((line = reader.readLine()) != nul... |
11 | Code Sample 1:
public static String computeDigest(String str, String alg) { MessageDigest currentAlgorithm = null; try { currentAlgorithm = MessageDigest.getInstance(alg); } catch (NoSuchAlgorithmException e) { return str; } currentAlgorithm.reset(); currentAlgorithm.update(str.getBytes()); byte[] hash = currentAlgorit... |
00 | Code Sample 1:
public static void copyFile(String fromPath, String toPath) { try { File inputFile = new File(fromPath); String dirImg = (new File(toPath)).getParent(); File tmp = new File(dirImg); if (!tmp.exists()) { tmp.mkdir(); } File outputFile = new File(toPath); if (!inputFile.getCanonicalPath().equals(outputFile... |
00 | Code Sample 1:
public Document searchRelease(String id) throws Exception { Document doc = null; URL url = new URL("http://" + disgogsUrl + "/release/" + id + "?f=xml&api_key=" + apiKey[0]); HttpURLConnection uc = (HttpURLConnection) url.openConnection(); uc.addRequestProperty("Accept-Encoding", "gzip"); BufferedReader ... |
00 | Code Sample 1:
public static void main(String args[]) { if (args.length < 1) { System.err.println("usage: java copyURL URL [LocalFile]"); System.exit(1); } try { URL url = new URL(args[0]); System.out.println("Opening connection to " + args[0] + "..."); URLConnection urlC = url.openConnection(); InputStream is = url.op... |
00 | Code Sample 1:
private PrecomputedAnimatedModel loadPrecomputedModel_(URL url) { if (precompCache.containsKey(url.toExternalForm())) { return (precompCache.get(url.toExternalForm()).copy()); } TextureLoader.getInstance().getTexture(""); List<SharedGroup> frames = new ArrayList<SharedGroup>(); Map<String, Animation> ani... |
00 | Code Sample 1:
private static String webService(String strUrl) { StringBuffer buffer = new StringBuffer(); try { URL url = new URL(strUrl); InputStream input = url.openStream(); String sCurrentLine = ""; InputStreamReader read = new InputStreamReader(input, "utf-8"); BufferedReader l_reader = new java.io.BufferedReader... |
11 | Code Sample 1:
private String processFileUploadOperation(boolean isH264File) { String fileType = this.uploadFileFileName.substring(this.uploadFileFileName.lastIndexOf('.')); int uniqueHashCode = UUID.randomUUID().toString().hashCode(); if (uniqueHashCode < 0) { uniqueHashCode *= -1; } String randomFileName = uniqueHash... |
11 | Code Sample 1:
static List<String> listProperties(final MetadataType type) { List<String> props = new ArrayList<String>(); try { File adapter = File.createTempFile("adapter", null); InputStream stream = Thread.currentThread().getContextClassLoader().getResourceAsStream(type.adapter); if (stream == null) { throw new Ill... |
11 | Code Sample 1:
protected static byte[] downloadAndSendBinary(String u, boolean saveOnDisk, File f) throws IOException { URL url = new URL(u); Authenticator.setDefault(new HTTPResourceAuthenticator()); HTTPResourceAuthenticator.addURL(url); logger.debug("Retrieving " + url.toString()); ByteArrayOutputStream bytes = new ... |
00 | Code Sample 1:
public static void executa(String arquivo, String filial, String ip) { String drive = arquivo.substring(0, 2); if (drive.indexOf(":") == -1) drive = ""; Properties p = Util.lerPropriedades(arquivo); String servidor = p.getProperty("servidor"); String impressora = p.getProperty("fila"); String arqRel = ne... |
11 | Code Sample 1:
public static void copyFile(File in, File out) throws IOException { FileChannel inChannel = new FileInputStream(in).getChannel(); FileChannel outChannel = new FileOutputStream(out).getChannel(); try { inChannel.transferTo(0, inChannel.size(), outChannel); } catch (IOException e) { throw e; } finally { if... |
00 | Code Sample 1:
public String getWeather(String cityName, String fileAddr) { try { URL url = new URL("http://www.google.com/ig/api?hl=zh_cn&weather=" + cityName); InputStream inputstream = url.openStream(); String s, str; BufferedReader in = new BufferedReader(new InputStreamReader(inputstream)); StringBuffer stringbuff... |
11 | Code Sample 1:
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 = DcmObjectFactory.getInstance... |
11 | Code Sample 1:
public ActionResponse executeAction(ActionRequest request) throws Exception { BufferedReader in = null; try { CurrencyEntityManager em = new CurrencyEntityManager(); String id = (String) request.getProperty("ID"); CurrencyMonitor cm = getCurrencyMonitor(em, Long.valueOf(id)); String code = cm.getCode(); ... |
11 | Code Sample 1:
public static Document validateXml(File messageFile, URL inputUrl, String[] catalogs) throws IOException, ParserConfigurationException, Exception, SAXException, FileNotFoundException { InputSource source = new InputSource(inputUrl.openStream()); Document logDoc = DomUtil.getNewDom(); XMLReader reader = S... |
00 | Code Sample 1:
@Override protected URLConnection openConnection(URL url) throws IOException { try { final HttpServlet servlet; String path = url.getPath(); if (path.matches("reg:.+")) { String registerName = path.replaceAll("reg:([^/]*)/.*", "$1"); servlet = register.get(registerName); if (servlet == null) throw new Ru... |
00 | Code Sample 1:
public LOCKSSDaemonStatusTableTO getDataFromDaemonStatusTable() throws HttpResponseException { LOCKSSDaemonStatusTableXmlStreamParser ldstxp = null; LOCKSSDaemonStatusTableTO ldstTO = null; HttpEntity entity = null; HttpGet httpget = null; xstream.setMode(XStream.NO_REFERENCES); xstream.alias("HttpClient... |
00 | Code Sample 1:
public static String exchangeForSessionToken(String protocol, String domain, String onetimeUseToken, PrivateKey key) throws IOException, GeneralSecurityException, AuthenticationException { String sessionUrl = getSessionTokenUrl(protocol, domain); URL url = new URL(sessionUrl); HttpURLConnection httpConn ... |
11 | Code Sample 1:
public static int fileCopy(String strSourceFilePath, String strDestinationFilePath, String strFileName) throws IOException { String SEPARATOR = System.getProperty("file.separator"); File dir = new File(strSourceFilePath); if (!dir.exists()) dir.mkdirs(); File realDir = new File(strDestinationFilePath); i... |
00 | Code Sample 1:
private static String getDigestPassword(String streamId, String password) { MessageDigest md = null; try { md = MessageDigest.getInstance("SHA"); } catch (NoSuchAlgorithmException e) { throw (RuntimeException) new IllegalStateException().initCause(e); } md.update((streamId + password).getBytes()); byte[]... |
11 | Code Sample 1:
public static String encryptPassword(String password) { try { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(password.getBytes()); byte[] hash = md.digest(); int hashLength = hash.length; StringBuffer hashStringBuf = new StringBuffer(); String byteString; int byteLength; for (int index = ... |
00 | Code Sample 1:
public FlatFileFrame() { super("Specify Your Flat File Data"); try { Class transferAgentClass = this.getStorageTransferAgentClass(); if (transferAgentClass == null) { throw new RuntimeException("Transfer agent class can not be null."); } Class[] parameterTypes = new Class[] { RepositoryStorage.class }; C... |
11 | Code Sample 1:
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("<html><head><title>LOC Diff... |
11 | Code Sample 1:
public static byte[] ComputeForBinary(String ThisString) throws Exception { byte[] Result; MessageDigest MD5Hasher; MD5Hasher = MessageDigest.getInstance("MD5"); MD5Hasher.update(ThisString.getBytes("iso-8859-1")); Result = MD5Hasher.digest(); return Result; }
Code Sample 2:
private static MyCookieData ... |
00 | Code Sample 1:
private String doExecute(AbortableHttpRequest method) throws Throwable { HttpClient client = CLIENT.newInstance(); HttpResponse rsp = client.execute((HttpUriRequest) method); HttpEntity entity = rsp.getEntity(); if (entity == null) throw new RequestError("No entity in method"); InputStream in = null; try... |
11 | Code Sample 1:
private String signMethod() { String str = API.SHARED_SECRET; Vector<String> v = new Vector<String>(parameters.keySet()); Collections.sort(v); for (String key : v) { str += key + parameters.get(key); } MessageDigest m = null; try { m = MessageDigest.getInstance("MD5"); m.update(str.getBytes(), 0, str.len... |
00 | Code Sample 1:
@Override protected RequestLogHandler createRequestLogHandler() { try { File logbackConf = File.createTempFile("logback-access", ".xml"); IOUtils.copy(Thread.currentThread().getContextClassLoader().getResourceAsStream("logback-access.xml"), new FileOutputStream(logbackConf)); RequestLogHandler requestLog... |
11 | Code Sample 1:
public void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ServletContext context = getServletContext(); String forw = null; try { int maxUploadSize = 50000000; MultipartRequest multi = new MultipartRequest(request, ".", maxUploadSize); String des... |
00 | Code Sample 1:
public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { HttpClientInfo clientInfo = HttpUtil.parseClientInfo((HttpServletRequest) request); if (request.getParameter("_debug_") != null) { StringBuffer buffer = new StringBuffer(); Enumeration iter = re... |
00 | Code Sample 1:
static Object executeMethod(HttpMethod method, int timeout, boolean array) throws HttpRequestFailureException, HttpException, IOException, HttpRequestTimeoutException { try { method.getParams().setSoTimeout(timeout * 1000); int status = -1; Object result = null; System.out.println("Execute method: " + me... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.