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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:13:27+00:00 2026-06-14T20:13:27+00:00

I am writing a program that, given a file consisting of words and associated

  • 0

I am writing a program that, given a file consisting of words and associated objects, creates a dictionary. For instance, I may have the word “Apple” associated with the String object “A red fruit”

Now, some of the objects are image files, and some are audio files. Of the image files, only the extensions “.jpg” and “.gif” will be considered (i.e. included in the file). Likewise, for the audio files, only “.wav” and “.mid” will be considered.

I have classes to handle displaying the image files and playing the audio files already, but I am now trying to figure out (when inputting the information) how to detect if an object is an image or audio file, or if it is neither. I was thinking of somehow checking the last three characters of the object, so for instance if it is “jpg” then I would mark it as an image type object. Or, if it was “uit” as in the “Apple” example above, then it would be marked as neither. However, I don’t know how to check only the last three characters of a string. Is there some built-in method to do this String check automatically?

  • 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-14T20:13:28+00:00Added an answer on June 14, 2026 at 8:13 pm

    Checking the last 3 characters of the file name is not a good way, I think. You can check the characters starting from the last index of ‘.’ (dot) just like in this utility method:

    public static String getFileExtension(String fileName) 
    {
        if (fileName == null || fileName.equals("") || !fileName.contains("."))
            return "";
    
        return fileName.substring(fileName.lastIndexOf('.'), fileName.length());
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a program that's parsing an XML file to java objects using smooks.
I'm writing a program that among other things needs to download a file given
I'm currently writing a Perl program that is to read a given file (either
I'm writing a program that uses File I/O to traverse through a directory given
I'm writing a program in C that basically creates an archive file for a
I'm writing a program that deciphers sentences, syllables, and words given in a basic
Im writing a program that should read input via stdin, so I have the
I'm writing a program that reads huge file (3x280 GB) and does a fitting
I am writing a program that sets up a file path that I use
I'm writing a program that uses FileSystemWatcher to monitor changes to a given directory,

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.