<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.theeggeadventure.com/wikimedia/index.php?action=history&amp;feed=atom&amp;title=Java_Basename</id>
	<title>Java Basename - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.theeggeadventure.com/wikimedia/index.php?action=history&amp;feed=atom&amp;title=Java_Basename"/>
	<link rel="alternate" type="text/html" href="https://www.theeggeadventure.com/wikimedia/index.php?title=Java_Basename&amp;action=history"/>
	<updated>2026-05-13T10:33:55Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.46.0-beta</generator>
	<entry>
		<id>https://www.theeggeadventure.com/wikimedia/index.php?title=Java_Basename&amp;diff=2264&amp;oldid=prev</id>
		<title>Egge: Created page with &#039;Ruby contains a nice build in function to get the basename of a file. &lt;geshi&gt; File.basename(&#039;https://www.theeggeadventure.com/wikimedia/index.php&#039;) =&gt; &quot;index.php&quot; &lt;/geshi&gt;  The h…&#039;</title>
		<link rel="alternate" type="text/html" href="https://www.theeggeadventure.com/wikimedia/index.php?title=Java_Basename&amp;diff=2264&amp;oldid=prev"/>
		<updated>2009-10-15T04:47:34Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;#039;Ruby contains a nice build in function to get the basename of a file. &amp;lt;geshi&amp;gt; File.basename(&amp;#039;https://www.theeggeadventure.com/wikimedia/index.php&amp;#039;) =&amp;gt; &amp;quot;index.php&amp;quot; &amp;lt;/geshi&amp;gt;  The h…&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Ruby contains a nice build in function to get the basename of a file.&lt;br /&gt;
&amp;lt;geshi&amp;gt;&lt;br /&gt;
File.basename(&amp;#039;https://www.theeggeadventure.com/wikimedia/index.php&amp;#039;)&lt;br /&gt;
=&amp;gt; &amp;quot;index.php&amp;quot;&lt;br /&gt;
&amp;lt;/geshi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The handy function is not present in the JDK.  Here&amp;#039;s my Java version of the function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;geshi&amp;gt;&lt;br /&gt;
	private static final Pattern BASENAME = Pattern.compile(&amp;quot;.*?([^/]*)$&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
	public static String basename(URL url) {&lt;br /&gt;
		return basename(url.getPath());&lt;br /&gt;
	}&lt;br /&gt;
	&lt;br /&gt;
	public static String basename(String url) {&lt;br /&gt;
		Matcher matcher = BASENAME.matcher(url);&lt;br /&gt;
		if (matcher.matches()) {&lt;br /&gt;
			return matcher.group(1);&lt;br /&gt;
		} else {&lt;br /&gt;
			throw new IllegalArgumentException(&amp;quot;Can&amp;#039;t parse &amp;quot; + url);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/geshi&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Java]]&lt;/div&gt;</summary>
		<author><name>Egge</name></author>
	</entry>
</feed>