I am writing a little class and I encountered a problem.
This class reads CSV file, there will be only one value for each key. I have
class CSVMap<T> extends AbstractMap<String,T>
and I have:
public void load(String filename)
{
try
{
BufferedReader out=new BufferedReader(new FileReader(filename));
String []tab;
T value;
while(out.ready());
{
tab=out.readLine().split(",");
}
} catch (IOException e)
{
e.printStackTrace();
}
}
now I need to create new instances of T to put them in my map ( I know that T has constructor that takes string).
I know about type-erasure in Java so only way out of this is a) passing T.Class to my load method or keeping it somewhere private in my class or b) keeping some private object T and using it in method to get Class object?
I am asking because I wanted to be sure if there isn't any other way to do it.