GleasonK
GleasonK

Reputation: 1022

Preset Map in Java

I have an analytics program that receives many values from a HTTP GET request and maps them into a table. My question pertains to changing the shorthand names I assigned to variables in the request into more full names before I write them to a log file. What is the best way for mapping the shorthand (e.g uid: KG) to the full names (User ID: KG )?

Currently I have a Map that puts all the relations in it ("uid": "User ID") on runtime. It uses a good number of calls to put every value in the map so I was wondering what is standard practice or most efficient, many put calls or is there a way to save a standard map to a file and load it in runtime?

Upvotes: 0

Views: 560

Answers (1)

chubbsondubs
chubbsondubs

Reputation: 38696

Load a Properties object from a file is probably your best option. Instead of hard coding them in your program you can put them in a properties file like so:

uid=User ID bid=Billy ID ...

THen load them using this API:

http://docs.oracle.com/javase/7/docs/api/java/util/Properties.html

Upvotes: 1

Related Questions