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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:14:04+00:00 2026-06-09T09:14:04+00:00

I am using a class where I am taking input as the file name

  • 0

I am using a class where I am taking input as the file name and the file location. I have a pre defined file names, so I will match the predefined file names with the file name that I received and then store the values accordingly. Please look at the code below

//Set of storage maps and tables 
public class storage
{
//Storage set
public static Set<Integer> tiger = new HashSet<Integer>();

//Storage set
public static Set<Integer> lion = new HashSet<Integer>();

//This is the table used for storing the browser customer count  
public static Table<String,String,Integer> elephant = HashBasedTable.create(); 

//Storage map 
public static Map<String, String> monkey = new HashMap<String, String>();


public static void storeDataDirector(String fileLocation,String fileName) throws     Exception 
{
    if (fileName = monkey) 
                **update the "monkey map"**

}

This is my problem, also I have lot of maps and tables to be used so I wouldn’t be able to use multiple if conditions and then check and update the same.

What I would like to know is the below

As I have said earlier, The file name that I am sending to the program which is “String filename” has the same name of the “Map monkey” but the former is a String and the latter is the map. I would like to know if I will be able to use the string variable as a reference to the map instance as both of them have the same name . This will highly avoid the if conditions that I am using in the program and thus I would like to possible solution for this … Anything related to type caseting ort

  • 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-09T09:14:05+00:00Added an answer on June 9, 2026 at 9:14 am

    The idea is to relate them in a Map, and use the file name as a key for example

    Map<String, Map<String, String>>
    //  file    store structure
    

    If you need a generic solution, you could solve this by implementing an abstraction of your store structure, by implementing an interface similar to this one:

    // T is the store type and U is the original type (String from file for instance...)
    public interface StoreUnit<T, U> {
    
        void update(U record);
    
        List<T> list();
    
    }
    

    so you will have an implementation for each case (Set, Map, Table …) and will relate it in a map using the file name as key.

    monkeyFileName => MapStoreUnit<Entry<String,String>,String>
    tigerFileName => SetStoreUnit<Integer, String>
    elephantFileName => TableStoreUnit<Entry<Entry<String,String>,String>,String> // not sure if for Table there is something better than Entry ;)
    

    When you wanna update some store you perform a get over the map using the file name as key, and invoking update method implemented with the record (that could be an String, complex Object) and so on. When you need to read something from there you could use the list method.

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

Sidebar

Related Questions

Using class name I am firing a click event in jquery. Class names are
I have an input file that I want to sort based on timestamp which
I have a .xib file where the user can enter a location name of
I am taking pictures from the iPhone camera using the UIImagePickerController Class. I am
I'm writing a screen capture module using the Robot class. I'm taking screenshots of
We are taking db backups programatically by using SqlServer.Management.Smo.Backup class. It is working perfectly.
Problem! I Have the following input (rules) from a flat file (talking about numeric
I have a program that takes in a data file of students that have
Say that I have one constructor that takes an input and another that uses
I have a form that validates using jquery. The form's id is contact and

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.