Results 1 to 11 of 11
- 12-07-2010, 07:04 AM #1
Member
- Join Date
- Dec 2010
- Posts
- 14
- Rep Power
- 0
Error: "The method startsWith(String, String) is undefined for the type StringUtils"
Hii,
I got an error during compiling the below line: Error: "The method startsWith(String, String) is undefined for the type StringUtils"
code: if (StringUtils.isBlank (line) || StringUtils.startsWith (line, "#"))
I have imported all the required packages ( import org.apache.commons.lang.StringUtils; ..) and jars..
Please anyone let me know what the error was..
Thanks
Shihad S
- 12-07-2010, 07:17 AM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,399
- Blog Entries
- 7
- Rep Power
- 17
- 12-07-2010, 08:37 AM #3
Member
- Join Date
- Dec 2010
- Posts
- 14
- Rep Power
- 0
Error: "The method startsWith(String, String) is undefined for the type StringUtils"
Thanks josAH for your reply.....
But class "StringUtils" have the method startsWith(string, string) I have checked and confirmed that..
- 12-07-2010, 08:48 AM #4
Member
- Join Date
- Dec 2010
- Posts
- 19
- Rep Power
- 0
hi,
try
String line="xxxxxxxxxxxxxxxxxxx";
boolean result=line.startsWith("#");
- 12-07-2010, 08:51 AM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,399
- Blog Entries
- 7
- Rep Power
- 17
Correction: indeed it has; show us your code and the complete error message please.
kind regards,
JosLast edited by JosAH; 12-07-2010 at 08:54 AM.
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 12-07-2010, 08:57 AM #6
Member
- Join Date
- Dec 2010
- Posts
- 14
- Rep Power
- 0
Hi josAH,
Just check this link. It specifies the method startsWith(string, string) in the class StringUtils
Commons Lang 2.5 API
- 12-07-2010, 09:05 AM #7
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,399
- Blog Entries
- 7
- Rep Power
- 17
- 12-07-2010, 09:12 AM #8
Member
- Join Date
- Dec 2010
- Posts
- 14
- Rep Power
- 0
Hi josAH,
Error is solved. i tried Mr. SmilingKey's suggestion..: " line.startsWith("#") ". Now it is working.. Thanks for all your replies. Expecting your co-operation in the future also..
Thanks
Shihad S
- 12-07-2010, 10:24 AM #9
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,399
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 12-07-2010, 10:37 AM #10
Member
- Join Date
- Dec 2010
- Posts
- 14
- Rep Power
- 0
Ya, thats right.. My actual code is given below:
-----------------------------------------------------------
private List<String> loadTestValues (String _resourceName) throws IOException
{
final InputStream testFileStream = getClass ().getClassLoader ().getResourceAsStream (_resourceName);
List<String> lines;
try
{
assertNotNull ("unable to find " + _resourceName, testFileStream);
lines = IOUtils.readLines (testFileStream);
}
finally
{
IOUtils.closeQuietly (testFileStream);
}
final Iterator<String> i = lines.iterator ();
while (i.hasNext ())
{
final String line = i.next ();
if (StringUtils.isBlank (line) || StringUtils.startsWith (line, "#"))
{
i.remove ();
}
}
return lines;
}
-------------------------------------------------------------------------
Line marked in bold causes the error: "The method startsWith(String, String) is undefined for the type StringUtils". I dnt Know why the error is happening. I have imported all required packages and jar's.. Can you please try to find out that..
- 12-07-2010, 12:29 PM #11
Member
- Join Date
- Dec 2010
- Posts
- 19
- Rep Power
- 0
Similar Threads
-
The method myFunction(String) is undefined for the type
By jfill in forum New To JavaReplies: 2Last Post: 05-07-2010, 11:02 PM -
string comparison with "=" and ".equal"
By guavajuice in forum New To JavaReplies: 9Last Post: 04-22-2010, 09:01 PM -
jsp insert into database error(java.lang.NumberFormatException: For input string: "")
By cypher_girl in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 12-22-2009, 03:14 AM -
How can I prevent "found void but expected java.lang.String" ?
By trueblue in forum New To JavaReplies: 3Last Post: 05-21-2009, 03:48 PM -
final String currentWorld = "Java Forums"; String.format("Hello %s", currentWorld);
By mcfrog in forum IntroductionsReplies: 0Last Post: 04-02-2009, 07:02 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks