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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T08:40:53+00:00 2026-05-21T08:40:53+00:00

I’ve got some files in the relative directory (directory the app is running in)

  • 0

I’ve got some files in the relative directory (directory the app is running in) starting with ‘@’ and I need to open all of them in java. Show me a way to accomplish it. If it helps, I’m working on netbeans.They’re basically .ser files. So I have to fetch the objects in them

  • 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-21T08:40:54+00:00Added an answer on May 21, 2026 at 8:40 am
    File dir = new File(".");
    if(!dir.isDirectory()) throw new IllegalStateException("wtf mate?");
    for(File file : dir.listFiles()) {
        if(file.getName().startsWith("@"))
            process(file);
    }
    

    After revisiting this, it turns out there’s something else you can do. Notice the file filter I used.

    import java.io.File;
    class Test {
        public static void main(String[] args) {
            File dir = new File(".");
            if(!dir.isDirectory()) throw new IllegalStateException("wtf mate?");
            for(File file : dir.listFiles(new RegexFileFilter("@*\\.ser"))) {
                    process(file);
            }
        }
    
        public static void process(File f) {
            System.out.println(f.getAbsolutePath());
        }
    }
    

    Here’s the RegexFileFilter I used

    public class RegexFileFilter implements java.io.FileFilter {
    
        final java.util.regex.Pattern pattern;
    
        public RegexFileFilter(String regex) {
            pattern = java.util.regex.Pattern.compile(regex);
        }
    
        public boolean accept(java.io.File f) {
            return pattern.matcher(f.getName()).find();
        }
    
    }
    

    And here’s the result. Note the three good files and the three bad files. If you had to do this on a more regular basis, I’d recommend using this, especially if you need to do it based on other attributes of the file other than file name, like length, modify date, etc.

    C:\junk\j>dir
     Volume in drive C has no label.
     Volume Serial Number is 48FA-B715
    
     Directory of C:\junk\j
    
    02/14/2012  06:16 PM    <DIR>          .
    02/14/2012  06:16 PM    <DIR>          ..
    02/14/2012  06:15 PM                 0 @bad.serr
    02/14/2012  06:15 PM                 0 @badser
    02/14/2012  06:15 PM                 0 @first.ser
    02/14/2012  06:15 PM                 0 @second.ser
    02/14/2012  06:15 PM                 0 @third.ser
    02/14/2012  06:15 PM                 0 bad@file.ser
    02/14/2012  06:24 PM               692 RegexFileFilter.class
    02/14/2012  06:24 PM               338 RegexFileFilter.java
    02/14/2012  06:24 PM               901 Test.class
    02/14/2012  06:24 PM               421 Test.java
                  10 File(s)          2,352 bytes
                   2 Dir(s)  10,895,474,688 bytes free
    
    C:\junk\j>java Test
    @first.ser
    @second.ser
    @third.ser
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

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.