DolphaGo / TIL

TIL & issues
0 stars 1 forks source link

[Java] URI #13

Open DolphaGo opened 3 years ago

DolphaGo commented 3 years ago
@Test
void test4() throws URISyntaxException {
    URI uri = new URI("https://api.naver.com/DolphaGo/abcdefghijklmn/Test?PageSize=1&Page=3&EndDate=2021-07-07T15%3A00%3A00Z&StartDate=2020-01-17T15%3A00%3A00Z");

    final String path = uri.getPath();
    System.out.println("path = " + path);
    final String rawPath = uri.getRawPath();
    System.out.println("rawPath = " + rawPath);

    final String query = uri.getQuery();
    System.out.println("query = " + query);
    final String rawQuery = uri.getRawQuery();
    System.out.println("rawQuery = " + rawQuery);

    final URI result = new URIBuilder()
            .setScheme("https")
            .setHost("www.naver.com")
            .setPath(path)
            .setCustomQuery(query)
            .build();

    System.out.println("result = " + result);
}

결과

path = /DolphaGo/abcdefghijklmn/Test
rawPath = /DolphaGo/abcdefghijklmn/Test
query = PageSize=1&Page=3&EndDate=2021-07-07T15:00:00Z&StartDate=2020-01-17T15:00:00Z
rawQuery = PageSize=1&Page=3&EndDate=2021-07-07T15%3A00%3A00Z&StartDate=2020-01-17T15%3A00%3A00Z
result = https://www.naver.com/DolphaGo/abcdefghijklmn/Test?PageSize=1&Page=3&EndDate=2021-07-07T15:00:00Z&StartDate=2020-01-17T15:00:00Z
DolphaGo commented 3 years ago

https://docs.oracle.com/javase/7/docs/api/java/net/URI.html#getRawPath()

image