Skip to content

Commit 23b3fc7

Browse files
committed
Polish FileSystemResource
1 parent 7175c4c commit 23b3fc7

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

spring-core/src/main/java/org/springframework/core/io/FileSystemResource.java

+19-8
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ public final String getPath() {
161161
/**
162162
* This implementation returns whether the underlying file exists.
163163
* @see java.io.File#exists()
164+
* @see java.nio.file.Files#exists(Path, java.nio.file.LinkOption...)
164165
*/
165166
@Override
166167
public boolean exists() {
@@ -172,6 +173,8 @@ public boolean exists() {
172173
* (and corresponds to an actual file with content, not to a directory).
173174
* @see java.io.File#canRead()
174175
* @see java.io.File#isDirectory()
176+
* @see java.nio.file.Files#isReadable(Path)
177+
* @see java.nio.file.Files#isDirectory(Path, java.nio.file.LinkOption...)
175178
*/
176179
@Override
177180
public boolean isReadable() {
@@ -180,8 +183,8 @@ public boolean isReadable() {
180183
}
181184

182185
/**
183-
* This implementation opens a NIO file stream for the underlying file.
184-
* @see java.io.FileInputStream
186+
* This implementation opens an NIO file stream for the underlying file.
187+
* @see java.nio.file.Files#newInputStream(Path, java.nio.file.OpenOption...)
185188
*/
186189
@Override
187190
public InputStream getInputStream() throws IOException {
@@ -198,6 +201,8 @@ public InputStream getInputStream() throws IOException {
198201
* (and corresponds to an actual file with content, not to a directory).
199202
* @see java.io.File#canWrite()
200203
* @see java.io.File#isDirectory()
204+
* @see java.nio.file.Files#isWritable(Path)
205+
* @see java.nio.file.Files#isDirectory(Path, java.nio.file.LinkOption...)
201206
*/
202207
@Override
203208
public boolean isWritable() {
@@ -207,7 +212,7 @@ public boolean isWritable() {
207212

208213
/**
209214
* This implementation opens a FileOutputStream for the underlying file.
210-
* @see java.io.FileOutputStream
215+
* @see java.nio.file.Files#newOutputStream(Path, java.nio.file.OpenOption...)
211216
*/
212217
@Override
213218
public OutputStream getOutputStream() throws IOException {
@@ -217,6 +222,7 @@ public OutputStream getOutputStream() throws IOException {
217222
/**
218223
* This implementation returns a URL for the underlying file.
219224
* @see java.io.File#toURI()
225+
* @see java.nio.file.Path#toUri()
220226
*/
221227
@Override
222228
public URL getURL() throws IOException {
@@ -226,6 +232,7 @@ public URL getURL() throws IOException {
226232
/**
227233
* This implementation returns a URI for the underlying file.
228234
* @see java.io.File#toURI()
235+
* @see java.nio.file.Path#toUri()
229236
*/
230237
@Override
231238
public URI getURI() throws IOException {
@@ -343,6 +350,7 @@ public Resource createRelative(String relativePath) {
343350
/**
344351
* This implementation returns the name of the file.
345352
* @see java.io.File#getName()
353+
* @see java.nio.file.Path#getFileName()
346354
*/
347355
@Override
348356
public String getFilename() {
@@ -353,6 +361,7 @@ public String getFilename() {
353361
* This implementation returns a description that includes the absolute
354362
* path of the file.
355363
* @see java.io.File#getAbsolutePath()
364+
* @see java.nio.file.Path#toAbsolutePath()
356365
*/
357366
@Override
358367
public String getDescription() {
@@ -361,16 +370,18 @@ public String getDescription() {
361370

362371

363372
/**
364-
* This implementation compares the underlying File references.
373+
* This implementation compares the underlying file paths.
374+
* @see #getPath()
365375
*/
366376
@Override
367-
public boolean equals(@Nullable Object other) {
368-
return (this == other || (other instanceof FileSystemResource &&
369-
this.path.equals(((FileSystemResource) other).path)));
377+
public boolean equals(@Nullable Object obj) {
378+
return (this == obj || (obj instanceof FileSystemResource other &&
379+
this.path.equals(other.path)));
370380
}
371381

372382
/**
373-
* This implementation returns the hash code of the underlying File reference.
383+
* This implementation returns the hash code of the underlying file path.
384+
* @see #getPath()
374385
*/
375386
@Override
376387
public int hashCode() {

0 commit comments

Comments
 (0)