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 8773605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:20:28+00:00 2026-06-13T18:20:28+00:00

I am studying Java and I am not really sure the way to searching

  • 0

I am studying Java and I am not really sure the way to searching file. I would like to build the function which returning file names ( the files name should begin with star and end with .txt)

For example, in the folder we have Java source file with some file. For example, files:

  • 1.txt
  • 2.txt
  • 4.txt
  • start.txt
  • star.txt
  • onstart.txt
  • starton.txt
  • myjava.java

Then I would like to get the start.txt, star.txt & starton.txt

I was looking for the FilenameFilter but I wasn’t able to find to good way to find file. Does any one know the way to find files?

  • 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-13T18:20:30+00:00Added an answer on June 13, 2026 at 6:20 pm
    // You'll need this import: import java.io.File;
    
    File folder = new File("C:/Folder_Location");
    // gets you the list of files at this folder
    File[] listOfFiles = folder.listFiles();
    // loop through each of the files looking for filenames that match
    for(int i = 0; i < listOfFile.length; i++){
        String filename = listOfFiles[i].getName();
        if(filename.startsWith("Stuff") && listOfFiles[i].getName().endsWith("OtherStuff")){
            // do something with the filename
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I began studying Java Regular Expression recently and I found some really intersting task.For
I'm studying for a programming interview in Java which may involve database access. Is
When studying Java I learned that Strings were not safe for storing passwords ,
I'm studying Java on my own. One of the exercises is the following, however
In studying for the OCP Java Programmer Exam, I was slightly surprised to see
I was studying about polymorphism. I couldn't determine the analogy in Java about these
Total noobie question here. I'm just learning Java, and studying passing arguments to functions.
I am studying the possibility of building Javascript applications in the Java / OSGi
I am learning java, and studying the following example from sun.com. import java.io.*; import
I'm studying Java. And i wanted to make the code for checking a 2D

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.