Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- Pattern fileExtensionPattern = Pattern.compile("\.\w+\z");
- boolean one = fileExtensionPattern.matcher("foo.bar").matches();
- boolean two = fileExtensionPattern.matcher("foo.b").matches();
- boolean three = fileExtensionPattern.matcher("foo.").matches();
- boolean four = fileExtensionPattern.matcher("foo").matches();
- System.out.println(one + " " + two + " " + three + " " + four);
- }
- public boolean isFilename(String filename) {
- int i=filename.lastInstanceOf(".");
- return(i != -1 && i != filename.length - 1)
- }
Add Comment
Please, Sign In to add comment