• 欢迎浏览“String me = Creater\忠实的资深Linux玩家;”,请文明浏览,理性发言,有侵犯你的权益请邮件我(creater@vip.qq.com).
  • 把任何的失败都当作一次尝试,不要自卑;把所有的成功都想成是一种幸运,不要自傲。
  •    3年前 (2015-08-11)  Android |   抢沙发  13 
    文章评分 0 次,平均分 0.0
     Uri uri = Uri.parse("http://127.0.0.1:8080/api/topics/nodeId/2-1-10");
            List<String> list = uri.getPathSegments();
            System.out.print("[1]");
            for(int i=0;i<list.size();i++)
                System.out.print(list.get(i));
            System.out.println();
    
            System.out.print("[2]");
            String path = uri.getEncodedPath();
            System.out.println(path);
    
            System.out.print("[3]");
            path = uri.getLastPathSegment();
            System.out.println(path);
    
            System.out.print("[4]");
            path = uri.getAuthority();
            System.out.println(path);
    
            System.out.print("[5]");
            path = uri.getHost();
            System.out.println(path);
    
            System.out.print("[6]");
            path = uri.getScheme();
            System.out.println(path);
    
            System.out.print("[7]");
            path = uri.getPath();
            System.out.println(path);
    

    测试结果:

    08-11 20:40:23.745  10313-10313/net.unix8.test I/System.out﹕ [1]apitopicsnodeId2-1-10
    08-11 20:40:23.745  10313-10313/net.unix8.test I/System.out﹕ [2]/api/topics/nodeId/2-1-10
    08-11 20:40:23.745  10313-10313/net.unix8.test I/System.out﹕ [3]2-1-10
    08-11 20:40:23.745  10313-10313/net.unix8.test I/System.out﹕ [4]127.0.0.1:8080
    08-11 20:40:23.745  10313-10313/net.unix8.test I/System.out﹕ [5]127.0.0.1
    08-11 20:40:23.745  10313-10313/net.unix8.test I/System.out﹕ [6]http
    08-11 20:40:23.745  10313-10313/net.unix8.test I/System.out﹕ [7]/api/topics/nodeId/2-1-10
    

    -----------------------------------------------

           Uri uri = Uri.parse("http://127.0.0.1:8080/api/topics/nodeId?id=1&curpage=2&pageSize=100");
            List<String> list = uri.getPathSegments();
            System.out.print("[1]");
            for(int i=0;i<list.size();i++)
                System.out.print(list.get(i));
            System.out.println();
    
            System.out.print("[2]");
            String path = uri.getEncodedPath();
            System.out.println(path);
    
            System.out.print("[3]");
            path = uri.getLastPathSegment();
            System.out.println(path);
    
            System.out.print("[4]");
            path = uri.getAuthority();
            System.out.println(path);
    
            System.out.print("[5]");
            path = uri.getHost();
            System.out.println(path);
    
            System.out.print("[6]");
            path = uri.getScheme();
            System.out.println(path);
    
            System.out.print("[7]");
            path = uri.getPath();
            System.out.println(path);
    
            System.out.print("[8]");
            path = uri.getQuery();
            System.out.println(path);
    08-11 21:46:58.240    8749-8749/net.unix8.test I/System.out﹕ [1]apitopicsnodeId
    08-11 21:46:58.240    8749-8749/net.unix8.test I/System.out﹕ [2]/api/topics/nodeId
    08-11 21:46:58.240    8749-8749/net.unix8.test I/System.out﹕ [3]nodeId
    08-11 21:46:58.240    8749-8749/net.unix8.test I/System.out﹕ [4]127.0.0.1:8080
    08-11 21:46:58.240    8749-8749/net.unix8.test I/System.out﹕ [5]127.0.0.1
    08-11 21:46:58.240    8749-8749/net.unix8.test I/System.out﹕ [6]http
    08-11 21:46:58.240    8749-8749/net.unix8.test I/System.out﹕ [7]/api/topics/nodeId
    08-11 21:46:58.240    8749-8749/net.unix8.test I/System.out﹕ [8]id=1&curpage=2&pageSize=100
     

    除特别注明外,本站所有文章均为String me = "Creater\忠实的资深Linux玩家";原创,转载请注明出处来自http://unix8.net/home.php/4239.html

    关于

    发表评论

    暂无评论

    切换注册

    登录

    忘记密码 ?

    切换登录

    注册

    扫一扫二维码分享