URI toString - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for URI toString method.

This code example shows how to use the following methods:getAuthority, getPath, toString
        ctx.revokeUriPermission(Uri.parse(rootUri), Intent.FLAG_GRANT_READ_URI_PERMISSION);
    } 
     
    public static File fileFromUri(Uri uri) throws IllegalArgumentException
    { 
        String authority = uri.getAuthority();
        if(isCorrectAuthority(authority))
            return new File(PATH_PREFIX + authority + uri.getPath());
        else throw new IllegalArgumentException("Unknown URI authority: " + authority);
    } 
     
    @Override 
    public ParcelFileDescriptor openFile(Uri uri, String mode)
        throws FileNotFoundException, SecurityException 
    { 
        Logger.T(TAG, "Opening content: " + uri);
         
        if(mode.compareTo("r") != 0)
        { 
            throw new SecurityException("Unacceptable openFile mode: " + mode);

8
CodeRank
This code example shows how to use the following methods:getPath, getScheme, toString
		InputStream stream = openInputStream( context, uri );
		if ( null == stream ) {
			return null; 
		} 
		 
		int orientation = ExifUtils.getExifOrientation( context, uri );
 
		Bitmap bitmap = null;
		int[] imageSize = new int[2];
		final boolean decoded = decodeImageBounds( stream, imageSize );
		IOUtils.closeSilently( stream );
 
		if ( decoded ) {
			int sampleSize;
			if( maxW < 0 || maxH < 0 ) {
				sampleSize = 1;
			} else { 
				sampleSize = computeSampleSize( imageSize[0], imageSize[1], (int) ( maxW * 1.2 ), (int) ( maxH * 1.2 ), orientation );
			} 
 

8
CodeRank
This code example shows how to use the following methods:getScheme, getSchemeSpecificPart, toString
  } 
 
  @Override 
  public DatabusSubscription decode(URI uri) throws DatabusException
  { 
    String scheme = uri.getScheme();
    String s = getScheme().equals(scheme) ? uri.getSchemeSpecificPart() : uri.toString();
 
    return DatabusSubscription.createSimpleSourceSubscription(s);
  } 
 
  @Override 
  public URI encode(DatabusSubscription sub)
  { 
    try 
    { 
      String uriSsc = DatabusSubscription.createStringFromSubscription(sub);
      URI result = uriSsc.indexOf(':') >=0 ? new URI(getScheme(), uriSsc, null) : new URI(uriSsc);
      return result;
    } 
8
CodeRank
This code example shows how to use the following methods:toString
  throws IOException { 
    if (null == userUri) {
      return Collections.emptyList();
    } 
     
    final Path userloc = new Path(userUri.toString());
    final Text rawUgi = new Text();
    final FileSystem fs = userloc.getFileSystem(conf);
    final ArrayList<UserGroupInformation> ugiList =
        new ArrayList<UserGroupInformation>();
 
    LineReader in = null;
    try { 
      in = new LineReader(fs.open(userloc));
      while (in.readLine(rawUgi) > 0) {//line is of the form username[,group]*
        if(rawUgi.toString().trim().equals("")) {
          continue; //Continue on empty line 
        } 
        // e is end position of user name in this line 
        int e = rawUgi.find(",");
7
CodeRank
This code example shows how to use the following methods:toString
        return new _RingtonePickerDialog(getContext(), intent, this).makeDialog();
    } 
 
    @Override 
    protected void onDialogClosed(boolean positiveResult) {
        String uri = mLastUri == null ? "" : mLastUri.toString();
        if (positiveResult && callChangeListener(uri)) {
            persistString(uri);
        } 
    } 
 
    @Override 
    protected Object onGetDefaultValue(TypedArray a, int index) {
        return a.getString(index);
    } 
 
    protected void onPrepareRingtonePickerIntent(Intent ringtonePickerIntent) {
        ringtonePickerIntent.putExtra(
                RingtoneManager.EXTRA_RINGTONE_EXISTING_URI,
                onRestoreRingtone()); 
7
CodeRank
This code example shows how to use the following methods:toString, toURL
	 * @throws MalformedURLException if the given URL specification is not valid 
	 * @see java.net.URI#URI(String, String, String) 
	 */ 
	public UrlResource(String protocol, String location, String fragment) throws MalformedURLException  {
		try { 
			this.uri = new URI(protocol, location, fragment);
			this.url = this.uri.toURL();
			this.cleanedUrl = getCleanedUrl(this.url, this.uri.toString());
		} 
		catch (URISyntaxException ex) {
			MalformedURLException exToThrow = new MalformedURLException(ex.getMessage());
			exToThrow.initCause(ex);
			throw exToThrow;
		} 
	} 
 
	/** 
	 * Determine a cleaned URL for the given original URL. 
	 * @param originalUrl the original URL 
	 * @param originalPath the original URL path 
7
CodeRank
This code example shows how to use the following methods:toString
 
    bridgeCallback.onResponse(TransportResponseImpl.<RestResponse>error(new Exception()));
 
    try 
    { 
      futureCallback.get(30, TimeUnit.SECONDS);
      Assert.fail("get should have thrown exception");
    } 
    catch (ExecutionException e)
    { 
      Assert.assertTrue(e.getCause().getMessage().contains(uri.toString()));
    } 
 
  } 
 
  @Test 
  public void testHttpToRestErrorMessage() throws TimeoutException, InterruptedException, ExecutionException 
  { 
    FutureCallback<RestResponse> futureCallback = new FutureCallback<RestResponse>();
    TransportCallback<RestResponse> callback =
7
CodeRank
This code example shows how to use the following methods:getHost, toString, toURL
    } 
    return out;
  } 
 
  public static URI unredirect(URI uri) throws IOException {
    if (!REDIRECTOR_DOMAINS.contains(uri.getHost())) {
      return uri;
    } 
    URL url = uri.toURL();
    HttpURLConnection connection = safelyOpenConnection(url);
    connection.setInstanceFollowRedirects(false);
    connection.setDoInput(false);
    connection.setRequestMethod("HEAD");
    connection.setRequestProperty("User-Agent", "ZXing (Android)");
    try { 
      int responseCode = safelyConnect(uri.toString(), connection);
      switch (responseCode) {
        case HttpURLConnection.HTTP_MULT_CHOICE:
        case HttpURLConnection.HTTP_MOVED_PERM:
        case HttpURLConnection.HTTP_MOVED_TEMP:
        case HttpURLConnection.HTTP_SEE_OTHER:
7
CodeRank
This code example shows how to use the following methods:getScheme, toString
   
  private ImageReader() { 
  } 
 
  public static BufferedImage readImage(URI uri) throws IOException {
    if ("data".equals(uri.getScheme())) {
      return readDataURIImage(uri);
    } 
    BufferedImage result;
    try { 
      result = ImageIO.read(uri.toURL());
    } catch (IllegalArgumentException iae) {
      throw new IOException("Resource not found: " + uri, iae);
    } 
    if (result == null) {
      throw new IOException("Could not load " + uri);
    } 
    return result;
  } 
   

7
CodeRank
This code example shows how to use the following methods:toString
 
		// create 
		Task task = randomTask();
 
		URI createdTaskUri = restTemplate.postForLocation(resourceUrl, task);
		System.out.println(createdTaskUri.toString());
		Task createdTask = restTemplate.getForObject(createdTaskUri, Task.class);
		assertThat(createdTask.getTitle()).isEqualTo(task.getTitle());
 
		// update 
		String id = StringUtils.substringAfterLast(createdTaskUri.toString(), "/");
		task.setId(new Long(id));
		task.setTitle(RandomData.randomName("Task"));
 
		restTemplate.put(createdTaskUri, task);
 
		Task updatedTask = restTemplate.getForObject(createdTaskUri, Task.class);
		assertThat(updatedTask.getTitle()).isEqualTo(task.getTitle());
 
		// delete 

7
CodeRank

Related URI toString Questions & Answers:

toString Method Overview
Returns the content of this URI as a string.
See Code Examples for other Java 8 URI Methods: