0

Get filename from sdcard which first name is "A" in java.

There are five pictures in my sdcard. Files name: A1.jpg A2.jpg A3.jpg B2.jpg C3.jpg

How can I get filename (A1.jpg A2.jpg A3.jpg) in java?

Chunhao
  • 91
  • 1
  • 8
  • 1
    Is this mobile framework related question? Can you please show us programming context about which you are talking about? – Miki Sep 20 '14 at 12:57

2 Answers2

0

In Java you can use .startsWith and use .getName() with File class (or .getFileName() with Path class)

Example

if (file.getName().startsWith("A")) {
 // ..
}
Marco Acierno
  • 14,682
  • 8
  • 43
  • 53
0

You can use a wildcard like this: How to find files that match a wildcard string in Java?

or you read all Files Read all files in a folder and filter them in Memory.

Community
  • 1
  • 1
joh.scheuer
  • 566
  • 3
  • 11