Hello,

The readability of usage example for FileSystems.newFileSystem would benefit from using a method to create a map from JEP 269: "Convenience Factory Methods for Collections." The current example is rendered in javadoc as

   Map<String,String> env = new HashMap<>();
   env.put("capacity", "16G");
   env.put("blockSize", "4k");
   FileSystem fs = FileSystems.newFileSystem(URI.create("memory:///?name=logfs"), env);

and the proposed replacement renders as

   FileSystem fs = FileSystems.newFileSystem(URI.create("memory:///?name=logfs"),
Map.of("capacity", "16G",
"blockSize", "4k"));

I've verified the replacement compiles.

Patch below.

Thanks,

-Joe

--- a/src/java.base/share/classes/java/nio/file/FileSystems.java Tue Apr 30 16:11:42 2019 -0700 +++ b/src/java.base/share/classes/java/nio/file/FileSystems.java Tue Apr 30 18:52:11 2019 -0700
@@ -252,10 +252,9 @@
      * Suppose there is a provider identified by the scheme {@code "memory"}
      * installed:
      * <pre>
-     *   Map&lt;String,String&gt; env = new HashMap&lt;&gt;();
-     *   env.put("capacity", "16G");
-     *   env.put("blockSize", "4k");
-     *   FileSystem fs = FileSystems.newFileSystem(URI.create("memory:///?name=logfs"), env); +     *   FileSystem fs = FileSystems.newFileSystem(URI.create("memory:///?name=logfs"),
+ * Map.of("capacity", "16G",
+ * "blockSize", "4k"));
      * </pre>
      *
      * @param   uri

Reply via email to