Reputation: 3205
I have a HashTable in which I have key value pairs like below : The values are separated by tab
<key, value>
Director, Chantal Akerman Aleksandr Sokurov Alexandra McGuinness
Country, Belgium-France Russia UK-Ireland UK-Ireland
I need to write the values in following structure in a tsv file:
Director Country
Chantal Akerman Belgium-France
Aleksandr Sokurov Russia
UK-Ireland
Carol Morley UK-Ireland
Is there any API available for the same in java. Or is there any other way around?
Upvotes: 2
Views: 106
Reputation: 14705
The problem easily solved by the standard tools.
Output keys:
List<Scanner> values = new ArrayList<Scanner>();
for( String title: hashTable.keySet() ){
out.print( title + "\t" );
Scanner sc = new Scanner(hasTable.get( title );
sc.useDelimiter("\t");
values.add();
}
out.println();
Output values:
while( values.get(0).hasNext() ){
for(int i = 0; i < values.size(); i++){
out.print( values.get(i).next() + "\t" );
}
out.println();
}
Upvotes: 1