I checked the place of concern of java.net.URL # getPath

The content of the article is verified with Java 8.

Overview

Make a note of how the'/' is handled in the character string obtained by getPath (), because I get excited every time I write the code.

Summary

Example

URL getPath()
http://host /
http://host/ /
http://host/path /path
http://host/path/ /path/
http://host?query /
http://host/?query /
http://host/path?query /path
http://host/path/?query /path/
http:// (Empty string)
http:/// /
http:///path /path

Points to keep in mind

path.startsWith("/path");
String a[]=path.split("/");
if(a[1].equals("path")) {} //The path is"/"Exception occurs in case of
path.endsWith("tail"); //"/path/tail/"If it is, it will be false

Recommended Posts

I checked the place of concern of java.net.URL # getPath
I checked the number of taxis with Ruby
I read the source of ArrayList I read
I read the source of Integer
I read the source of Long
I read the source of Short
I read the source of Byte
I read the source of String
I checked the automatic unit test creation tool (end of 2019 version)
I checked the specification of cols attribute of AsciiDoc table & internal implementation of Asciidoctor
I investigated the internal processing of Retrofit
[day: 5] I summarized the basics of Java
I used it without knowing the O / R mapping of rails, so I checked it.
Fall 2017 Security Specialist I checked the frequency of words that appeared in the morning 2
I want to output the day of the week
I understood the very basics of character input
I compared the characteristics of Java and .NET
I want to var_dump the contents of the intent
I touched on the new features of Java 15
I tried using the profiler of IntelliJ IDEA
Try the free version of Progate [Java I]
I checked this
I tried using the Server Push function of Servlet 4.0
Is drainTo of LinkedBlockingQueue safe? I followed the source
I was addicted to the record of the associated model
I tried to summarize the state transition of docker
I saw the list view of Android development collectively
05. I tried to stub the source of Spring Boot
I tried to reduce the capacity of Spring Boot
I tried the new feature profiler of IntelliJ IDEA 2019.2.
I want to know the answer of the rock-paper-scissors app
I want to display the name of the poster of the comment
I summarized the display format of the JSON response of Rails
I wrote a sequence diagram of the j.u.c.Flow sample
I summarized the types and basics of Java exceptions
[WIP] I tried the configuration of Docker + Streama + NFS
I am keenly aware of the convenience of graphql-code-generator, part 2
I can't get out of the Rails dbconsole screen
I learned about the existence of a gemspec file
I want to be aware of the contents of variables!
I want to return the scroll position of UITableView!
I checked the specification of how to specify cell attributes of AsciiDoc table & internal implementation of Asciidoctor