Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Buffered Readers and hashtables.  RSS feed

Karishma, Dixit
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

import java.util.*;
public class SS7Office
public static void main(String args[]) {
try {
final int TT_NUMBER=12; ;
BufferedReader br=new BufferedReader(new FileReader("ss7.con"));
Hashtable ht=new Hashtable();
String s=br.readLine();
while( s !=null ) {
StringTokenizer st=new StringTokenizer(s,"^");
String token = st.nextToken();
//System.out.println(" TOKEN IS "+token);
} else{
System.out.println(" TOKEN IS FOUND WITH 12");
for( int index=0; st.hasMoreTokens(); index++) {
ht.put( new Integer(index +1), st.nextToken());
ht.put(new Integer(39),new Integer(15));
ht.put(new Integer(43),new Integer(60));
ht.put(new Integer(45),new Integer(30));
ht.put(new Integer(47),new Integer(30));
ht.put(new Integer(49),new Integer(15));
ht.put(new Integer(51),new Integer(240));
ht.put(new Integer(21),new Integer(15));
ht.put(new Integer(23),new Integer(60));
ht.put(new Integer(25),new Integer(15));
ht.put(new Integer(27),new Integer(60));
ht.put(new Integer(29),new Integer(15));
ht.put(new Integer(31),new Integer(60));
ht.put(new Integer(33),new Integer(10));
ht.put(new Integer(53),new Integer(480));
ht.put(new Integer(55),new Integer(15));
ht.put(new Integer(71),new Integer(4));
ht.put(new Integer(67),new Integer(20));
ht.put(new Integer(65),new Integer(4));
ht.put(new Integer(35),new Integer(5));
ht.put(new Integer(37),new Integer(5));

System.out.println(" REPLACED VALUE IN HASH "+ht);
}catch(Exception e){
System.out.println(" Exception e"+e.toString());
My input file is ss7.con which i have to read till the 12th line,if it is not the 12th line ,I have to write it out to the screen,when I reach the 12th line I have to replace the values in the 12th line by those I have put in the hashtable.
The program does the above,but when it reaches the 12th line I have put the values to hashtable,but HOW do I write it to the file and display it on the screen.The final output on the screen must have all the llines in the i/p file includung the 12th line with the new replaced values.
Kindly help me.Thanks.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!