In Objective-C I use -[NSURL URLByDeletingLastPathComponent]
to get parent URL. What's the equivalent of this in Java?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Here is very simple solution which was the best approach in my use case:
I created simple function, I was inspired by the code of
File::getParent
. In my code there is no issue with back slashes on Windows. I assume thatresourcePath
is resource part of URL, without protocol, domain and port number. (e.g./articles/sport/atricle_nr_1234
)Shortest snippet of code I can think of is this:
I don't know of library function to do this in one step. However, the following (admittedly cumbersome) bit of code I believe accomplishes what you're after (and you could wrap this up in your own utility function):