Link to home
Create AccountLog in
Avatar of tom1234
tom1234Flag for Korea, Republic of

asked on

How can I import files using *.java

I want make a 'arrayList<File>'

so like this , new File("some/*.java");
using asterisk, all of java file in some folder are to be set into arrayList.

how can I do this?
Avatar of ksivananth
Flag of United States of America image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account

change it to with escape

Avatar of Valeri
just replace
return !name.startsWith(".");
return name.endsWith(".java");
ops, sorry, it's almost the same solution like ksivanant's one!
you can see also this:

change it to with escape


Globs won't work - they're a shell thing. You need to traverse per the examples
>> return name.matches( ".*\.java" ) ;

The below is more efficient and has exactly the same effect
return name.endsWith( ".java" ) ;

Open in new window