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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T00:40:27+00:00 2026-05-20T00:40:27+00:00

What I am trying to do is copy files from one folder to another.

  • 0

What I am trying to do is copy files from one folder to another. However, the twist is i was to copy all files from one folder which begin with say 123 and anything can follow.

For example i have a folder with 3 files, 123__sdf.jpg, 123034.jpg and 321.jpg.
I only want to copy the first two but how do I select them only. Because this application is dynamic the files can change thats why i only want to be able to select all files which begin with 123.

  • 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-05-20T00:40:28+00:00Added an answer on May 20, 2026 at 12:40 am

    First, you want to create a file pointing to the directory. Then, you can use the list method to get the list of files inside the directory. You can then use startsWith to check whether they start with 123 or not.

    File dir = new File("/the/dir/");
    if( dir.isDirectory() ){
        String[] files = dir.list();
        for (String string : files) {
            if( string.startsWith("123") ){
                File file = new File(dir, string);
                // do the copy stuff
            }
        }
    }
    

    list method returns a list of strings with files and directories, so you may want to use the isFile() method if you only want to copy files.

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

Sidebar

Related Questions

I am trying to copy files from one user's home directory to another user's
I am trying to copy files from one directory to another and test based
I am new to programming, trying to copy files from one location to another,
i want to copy all files and folders from one drive to another drive
Hi I am trying to writing a code which copy files from source folder
Basically I'm trying to copy a file from one place to another but I
I'm trying to get PowerShell to copy files from a remote computer (on which
I am trying to copy all format file (.txt,.pdf,.doc ...) file from source folder
I am trying to write a Python script that will copy files from one
I am creating a cron job in which I copy files from one directroy

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.