Skip to content

Commit

Permalink
Improve URIParser
Browse files Browse the repository at this point in the history
  • Loading branch information
tischi committed Oct 26, 2024
1 parent 8b30b85 commit 84a6207
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/test/java/develop/UriParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void main( String[] args ) throws URISyntaxException, MalformedURL
parseUri( new URI( "file:/Volumes/test" ) );
parseUri( new URI( "/Volumes/test" ) );
parseUri( new URI( "https://fiji.sc" ) );
parseUri( new URI("C:/test") );
parseUri( new URI( "C:/test") );
}

public static void parseUri( URI uri ) throws MalformedURLException, URISyntaxException
Expand All @@ -21,12 +21,12 @@ public static void parseUri( URI uri ) throws MalformedURLException, URISyntaxEx
{
System.out.println("--");
System.out.println("Missing schema, treating as file." );
treatAsFile( new URI( "file:" + uri ) );
asFile( new URI( "file:" + uri ) );
}
else if ( uri.getScheme().contains( "file" ) )
{
System.out.println("--");
treatAsFile( uri );
asFile( uri );
}
else if ( uri.getScheme().contains( "http" ) )
{
Expand All @@ -38,11 +38,11 @@ else if ( uri.getScheme().contains( "http" ) )
{
System.out.println("--");
System.out.println("Unknown schema: " + uri.getScheme() + ", treating as File." );
treatAsFile( new URI( "file:" + uri ) );
asFile( new URI( "file:" + uri ) );
}
}

private static void treatAsFile( URI uri ) throws MalformedURLException
private static void asFile( URI uri ) throws MalformedURLException
{
String path = uri.toURL().getPath();
File file = new File( path );
Expand Down

0 comments on commit 84a6207

Please sign in to comment.