URI之链接地址测试

2015年8月11日 由 Creater 留言 »
 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
广告位

发表评论

你必须 登陆 方可发表评论.