utility-method

Is there a utility method to separate a list by given string?

Is there something like the following in Apache Common Lang or Spring Utils or do you write your own Util method for this? List<String> list = new ArrayList<String>(); list.add("moo"); list.add("foo"); list.add("bar"); String enumeratedList = Util.enumerate(list, ", "); assert enumeratedList == "moo, foo, bar"; I remember the use of...

Utility method - Pass a File or String?

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 b...

If a "Utilities" class is evil, where do I put my generic code?

I generally live by the rule that Global variables / functions are evil and that every piece of code should live in the class to which it pertains. This is a very easy rule to follow, and I believe that I haven't ever run into an issue with this rule until now. Today, however, I need to add a function to my assembly rather than to a sp...

call a function in utility class

I have a function in a utility class namespace GUI.code { public class Utility { public string GetFileName(string grpID) { string filenameUNC = "\\\\" + "localhost" + "\\AgentShare\\"; string realPath = GetPath(filenameUNC); return realPath; } } } now i call this function from anoth...