I want to use functionality from a certain method in apache commons StringUtils. I currently do not have the option of just using the library as one would normally do. I found the source for the method I need and my question is: am I free (legally) to use this code (just a method out of the library) or do I have to use the entire library? If its ok, what kind of attribution would I need in my code, if any? Thanks.
You can certainly use just the methods that you want, provided that you follow the relevant terms of the Apache license. They say (among other things) that you must retain existing copyright notices, attribution and license notices. The license is easy to understand ... and if you are not comfortable that you fully understand it, consult an IP lawyer.