[Java] How to convert from String to Path type and get the path

In Java8, I needed a Path class to get the file path, but I wrote a memo because there was a situation where Strings were mixed during processing and I had to convert them one by one.

In conclusion, if you pass a String string as an argument with the resolve method of the Path class, you can recognize the entire path as a Path type.

Reference site: Path (Java Platform SE 8) https://docs.oracle.com/javase/jp/8/docs/api/java/nio/file/Path.html

The entire file path can be set with the arguments specified by the resolve method added.

Specific example: Path specified by Path type → / test / pathTest Path you want to add with String → hoge.txt

Result: Result of using resolve method → /test/pathTest/hoge.txt

I would appreciate it if you could tell me if the interpretation was different or if there is an easier way.

Recommended Posts

[Java] How to convert from String to Path type and get the path
[Java] How to convert a character string from String type to byte type
[Java] How to extract the file name from the path
[Java] Convert Object type null to String type
[Java] How to get the current directory
How to get the date in java
Type conversion from java BigDecimal type to String type
[Ruby] How to convert from lowercase to uppercase and from uppercase to lowercase
[Java] How to get and output standard input
How to get Class from Element in Java
How to get and study java SE8 Gold
[Java] How to get the redirected final URL
[Java] How to get the authority of the folder
[Java] How to get to the front of a specific string using the String class
How to get the absolute path of a directory running in Java
How to create your own annotation in Java and get the value
[Java] How to get the URL of the transition source
<java> Read Zip file and convert directly to string
Convert Java enum enums and JSON to and from Jackson
[Java] Program example to get the maximum and minimum values from an array
[Java] How to get the maximum value of HashMap
[Java] How to easily get the longest character string of ArrayList using stream
[Java] How to erase a specific character from a character string
How to convert A to a and a to A using AND and OR in Java
How to convert Java radix
How to get the date from the JavaScript Date type that C # developers are addicted to
[Ruby] How to get the tens place and the ones place
[Java] How to get the key and value stored in Map by iterative processing
How to get the class name / method name running in Java
Find the address class and address type from the IP address with Java
Difference between Java and JavaScript (how to find the average)
Get to the abbreviations from 5 examples of iterating Java lists
[IOS] How to get the table name from AWS DynamoDB
How to store a string from ArrayList to String in Java (Personal)
How to get the longest information from Twitter as of 12/12/2016
How to write and notes when migrating from VB to JAVA
I tried to convert a string to a LocalDate type in Java
Change only one character from the String type string to uppercase
[IOS14] How to get Data type image data directly from PHPickerViewController?
How to use Java HttpClient (Get)
How to convert LocalDate and Timestamp
The road from JavaScript to Java
How to use Java enum type
[Rails] How to get the URL of the transition source and redirect
[Swift5] How to get an array and the complement of arrays
From fledgling Java (3 years) to Node.js (4 years). And the impression of returning to Java
I tried to summarize the methods of Java String and StringBuilder
How to check for the contents of a java fixed-length string
How to get the length of an audio file in java
[Java] How to use the File class
[Java] How to use the hasNext function
[Java] How to use the HashMap class
Convert from java UTC time to JST time
[IOS] How to get data from DynamoDB
Studying how to use the constructor (java)
[Processing × Java] How to use the loop
How to output Java string to console screen
[Java] How to set the Date time to 00:00:00
[Processing × Java] How to use the class
Java: How to send values from Servlet to Servlet
How to install the legacy version [Java]