2727import java .io .IOException ;
2828import java .io .InputStream ;
2929import java .net .URL ;
30+ import java .nio .file .Paths ;
3031
3132/**
3233 * Static helper methods for loading {@code Stream}-backed resources.
@@ -120,7 +121,6 @@ public static boolean resourceExists(String resourcePath) {
120121 * @throws IOException if there is a problem acquiring the resource at the specified path.
121122 */
122123 public static InputStream getInputStreamForPath (String resourcePath ) throws IOException {
123-
124124 URL url = getURLForPath (resourcePath );
125125 if (url == null ) {
126126 throw new IOException ("Resource [" + resourcePath + "] could not be found." );
@@ -135,7 +135,7 @@ public static InputStream getInputStreamForPath(String resourcePath) throws IOEx
135135 * ({@link #CLASSPATH_PREFIX CLASSPATH_PREFIX},
136136 * {@link #URL_PREFIX URL_PREFIX}, or {@link #FILE_PREFIX FILE_PREFIX}). If the path is not prefixed by one
137137 * of these schemes, the path is assumed to be a file-based path that can be loaded with a
138- * call to {@link URI#create (String)}.
138+ * call to {@link Paths#get (String, String... )}.
139139 *
140140 * @param resourcePath the String path representing the resource to obtain.
141141 * @return the URL for the specified resource.
@@ -148,8 +148,10 @@ public static URL getURLForPath(String resourcePath) throws IOException {
148148 url = ClassUtils .getResource (stripPrefix (resourcePath ));
149149 } else if (resourcePath .startsWith (URL_PREFIX )) {
150150 url = URI .create (stripPrefix (resourcePath )).toURL ();
151+ } else if (resourcePath .startsWith (FILE_PREFIX )) {
152+ url = Paths .get (stripPrefix (resourcePath )).toUri ().toURL ();
151153 } else {
152- url = URI . create (resourcePath ).toURL ();
154+ url = Paths . get (resourcePath ). toUri ( ).toURL ();
153155 }
154156
155157 if (url == null ) {
0 commit comments