<div dir="auto">Hello <span class="gmail_chip gmail_plusreply" dir="auto"><a href="mailto:brian.burkhalter@oracle.com" style="color:#15c;text-decoration:underline">@brian.burkhalter@oracle.com</a></span>,<div dir="auto"><br></div><div dir="auto">Yes exactly.</div><div dir="auto"><br></div><div dir="auto">And I'm not trying to say that the method is underspecified -- the javadoc is fairly clear.</div><div dir="auto"><br></div><div dir="auto">I'm merely saying that this overload adds little value, while being a tripping hazard for those thinking the name describes the obvious.</div><div dir="auto"><br></div><div dir="auto">So, I'd like to deprecate the overload. Those who want the overload, just use the suggestion in the javadocs.</div></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Wed, Sep 10, 2025, 4:07 PM Brian Burkhalter <<a href="mailto:brian.burkhalter@oracle.com">brian.burkhalter@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="line-break:after-white-space">
Hello David,
<div><br>
</div>
<div>Redirecting to nio-dev.<br id="m_3985078471086206746lineBreakAtBeginningOfMessage">
<div><br>
<blockquote type="cite">
<div>On Sep 10, 2025, at 12:01 PM, David Alayachew <<a href="mailto:davidalayachew@gmail.com" target="_blank" rel="noreferrer">davidalayachew@gmail.com</a>> wrote:</div>
<br>
<div><span style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">One
would expect only fileZ.html to be printed out, but nothing does. The reason why is because path.endsWith(String) is effectively an alias for path.endsWith(Path.of(String)). The confusion being that Path.of(someString) is looking for a file or a directory.
Thus, since there is neither a file nor a folder called "html", the stream prints out nothing.</span></div>
</blockquote>
</div>
<br>
</div>
<div>The specification looks like it is pretty clear about the behavior, especially the implementation note in <a href="https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/nio/file/Path.html#endsWith(java.lang.String)" target="_blank" rel="noreferrer">Path.endsWith(String)</a>:</div>
<div><br>
</div>
<div>"<span style="font-family:-webkit-standard;font-size:medium">The default implementation is equivalent for this path to:</span></div>
<div>
<pre id="m_3985078471086206746snippet-endsWith(java.lang.String)1"><code> endsWith(getFileSystem().getPath(other));"</code></pre>
<pre id="m_3985078471086206746snippet-endsWith(java.lang.String)1"><font face="Helvetica">What you were expecting sounds like what would be given by</font></pre>
<pre id="m_3985078471086206746snippet-endsWith(java.lang.String)1"><div dir="auto" style="white-space:normal;font-family:Helvetica">.filter(path -> path.toString().endsWith("html”))</div><div dir="auto" style="white-space:normal;font-family:Helvetica"><br></div><div dir="auto" style="white-space:normal;font-family:Helvetica">or better</div><div dir="auto" style="white-space:normal;font-family:Helvetica"><br></div><div dir="auto" style="white-space:normal;font-family:Helvetica">.filter(path -> path.getFileName().toString().endsWith("html”))</div><div dir="auto" style="white-space:normal;font-family:Helvetica"><pre id="m_3985078471086206746snippet-endsWith(java.lang.String)1"><div><span style="font-family:Helvetica">Is that correct?</span></div></pre></div></pre>
<pre id="m_3985078471086206746snippet-endsWith(java.lang.String)1"><font face="Helvetica">If we could eventually agree on how to handle file extensions, that would help here.</font></pre>
<pre id="m_3985078471086206746snippet-endsWith(java.lang.String)1"><font face="Helvetica">Brian</font></pre>
</div>
</div>
</blockquote></div>