Utility method - Pass a File or String?
Posted
by James P.
on Stack Overflow
See other posts from Stack Overflow
or by James P.
Published on 2010-05-09T00:18:40Z
Indexed on
2010/05/09
0:38 UTC
Read the original article
Hit count: 561
Here's an example of a utility method:
public static Long getFileSize(String fileString) {
File file = new File(fileString);
if (file == null || !file.isFile())
return null;
return file.length();
}
Is it a good practise to pass a String rather than a File to a method like this? In general what reasoning should be applied when making utility methods of this style?
© Stack Overflow or respective owner