Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8802185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:01:37+00:00 2026-06-14T01:01:37+00:00

I wanted to know is there any specific method to filter file names and

  • 0

I wanted to know is there any specific method to filter file names and add specific files alone to a file array based on its prefix???

for example:
File: A_error_log.txt,A.txt,A.fasta,B.fasta,B_error_log.txt
From the above file list i just want to move the A type files to a folder and B type files to another folder.

A standard solution would be,get the list of files,then using get name check them for specific file name prefixes and add them.

I wanted to know is there any other method already present 4r this??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T01:01:38+00:00Added an answer on June 14, 2026 at 1:01 am

    If you can tolerate an extra external dependency the filefilter package of Apache Commons IO has many premade filters for this kind of operations, what you want is easy to do with the WildcardFileFilter:

     File dir = new File(".");
     FileFilter fileFilter = new WildcardFileFilter("A*");
     File[] files = dir.listFiles(fileFilter);
     for (int i = 0; i < files.length; i++) {
       System.out.println(files[i]);
     }
    

    There are many other filters, and a set of “logic” filters (AndFileFilter, OrFileFilter and NotFileFilter) that allow you to string several filters together.

    Should you decide to use Commons IO, in the FileUtils package there are a number of very interesting methods to move files around that also handle the case that a file has to be moved to another files system.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanted to know if there is any way to synchronize (or exchanging files)
I just wanted to know, if there is any technique to insert values into
i wanted to know if its possible to scroll to a specific Cell (determined
Wanted to know if there was a way one could query shelveset details from
I wanted to know if there is way to log the mysql queries in
Just wanted to know if there is a big chance to inject SQL While
I wanted to know if there's a way I can bind an Asp.net Ajax
I just wanted to know if there is a way on how to remove
I'm playing around with html client side storage and wanted to know if there
I know there are non-standard frameworks such as commons-validator, and hibernate validator. I wanted

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.