Skip to main content
added 4 characters in body
Source Link
freedev
  • 30.9k
  • 12
  • 129
  • 141

Java 11 and newer

This solution is better than others and more portable:

Path cwd = Path.of(“”"").toAbsolutePath();

Or even

String cwd = Path.of(“”"").toAbsolutePath().toString();

Java 11 and newer

This solution is better than others and more portable:

Path cwd = Path.of(“”).toAbsolutePath();

Or even

String cwd = Path.of(“”).toAbsolutePath().toString();

Java 11 and newer

This solution is better than others and more portable:

Path cwd = Path.of("").toAbsolutePath();

Or even

String cwd = Path.of("").toAbsolutePath().toString();
deleted 4 characters in body
Source Link
freedev
  • 30.9k
  • 12
  • 129
  • 141

Java 11 and newer

This solution is better than others and more portable:

Path cwd = PathsPath.getof(""“”).toAbsolutePath();

Or even

String cwd = PathsPath.getof(""“”).toAbsolutePath().toString();

Java 11 and newer

This solution is better than others and more portable:

Path cwd = Paths.get("").toAbsolutePath();

Or even

String cwd = Paths.get("").toAbsolutePath().toString();

Java 11 and newer

This solution is better than others and more portable:

Path cwd = Path.of(“”).toAbsolutePath();

Or even

String cwd = Path.of(“”).toAbsolutePath().toString();
added 4 characters in body; added 70 characters in body
Source Link
freedev
  • 30.9k
  • 12
  • 129
  • 141

Java 11 and newer

This solution is better than others and more portable:

Path cwd = Paths.get("").toAbsolutePath();

Or even

String cwd = Paths.get("").toAbsolutePath().toString();

Java 11 and newer

This solution is better than others and more portable:

String cwd = Paths.get("").toString();

Java 11 and newer

This solution is better than others and more portable:

Path cwd = Paths.get("").toAbsolutePath();

Or even

String cwd = Paths.get("").toAbsolutePath().toString();
deleted 73 characters in body
Source Link
freedev
  • 30.9k
  • 12
  • 129
  • 141
Loading
added 59 characters in body
Source Link
freedev
  • 30.9k
  • 12
  • 129
  • 141
Loading
added 14 characters in body
Source Link
freedev
  • 30.9k
  • 12
  • 129
  • 141
Loading
Source Link
freedev
  • 30.9k
  • 12
  • 129
  • 141
Loading