Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
AhFai Chan wrote:Since Windows' "\" is an escape character, I'll need to substring into strPath and copy one char at a time to an array and whenever there is an "\", I'll need to insert a second "\" immediately after that to escape it. Then I'll have to convert the array to a string object...
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Les Morgan wrote:Well... Windows will also use the "/", slash, character for separators in path.
Paweł Baczyński wrote:Do not compare Strings with == operator.
AvoidTheEqualityOperator (this is a link)
Winston Gutkowski wrote:
...
because Java (NOT Windows AFAIK; unless things have changed) will convert forward slashes into back ones for you if it works out it's running on a Windows environment.
AhFai Chan wrote:
Les Morgan wrote:Well... Windows will also use the "/", slash, character for separators in path.
Yes, "/" works, users will just have to input the path and file name with "/" rather than '"\"
Out on HF and heard nobody, but didn't call CQ? Nobody heard you either. 73 de N7GH
Stephan van Hulst wrote:Note that the File class is old and clunky, and should only be used when interfacing with older code. Use Path instead.
If you want to do this in a truly "separator agnostic" way, you can use Paths.get():
Stephan van Hulst wrote:Note that the File class is old and clunky, and should only be used when interfacing with older code. Use Path instead.
If you want to do this in a truly "separator agnostic" way, you can use Paths.get():
AhFai Chan wrote:Can you please explain the difference between Path and Paths in simple terms ?
Stephan van Hulst wrote:
AhFai Chan wrote:Can you please explain the difference between Path and Paths in simple terms ?
Path represents an actual path on a file system. It's the type we're interested in. It's an interface, because it may have different implementations across different file systems.
Paths is just a utility or helper class, that makes it easy for us to get instances of Path.
This is actually a common thing: The Java designers will create a type for us to use, and then make a utility class of which the name is the plural form. Another example is Collection and Collections.
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |