dcsimg
File IO !_NEWLINE_!pls answer urgent
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Robin_Rohit
Posted On:   Tuesday, February 26, 2002 07:36 AM

I have a file which is having 100 lines between the lines and words i have a delimiter i have to parse this file on the fly that is each time i parse and get one string this string has to be passed as a command for another function. I have to do this until the end of file. The file goes like this public void processCommand(JConnection jConn, Properties parameters, boolean flag ) { System.out.println("Flag :"+flag); ArrayList commandList = new ArrayList(); if ( jConn.status() != JConnConst.CONN_NO_ERROR ) { System.err.println( " " + "ERROR in send" + jConn.status() ); } else { try { /* BufferedRe   More>>

I have a file which is having 100 lines between the lines and words i have a delimiter i have to parse this file on the fly that is each time i parse and get one string this string has to be passed as a command for another function. I have to do this until the end of file.
The file goes like this

public void processCommand(JConnection jConn,
Properties parameters, boolean flag )
{
System.out.println("Flag :"+flag);
ArrayList commandList = new ArrayList();
if ( jConn.status() != JConnConst.CONN_NO_ERROR )
{
System.err.println( "
" + "ERROR in send" + jConn.status() );
}
else
{

try
{

/* BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
command = in.readLine();
command = command.toUpperCase();
//System.out.println(command);
*/

DataInputStream dis =new DataInputStream(new BufferedInputStream(new FileInputStream("command.properties")));
BufferedReader br = new BufferedReader(new InputStreamReader( dis));

while((command = br.readLine()) != null)
{
System.out.println("Command :"+command);
if ((command.equalsIgnoreCase("E"))
|| (command.equalsIgnoreCase("Q")))
{
closeConnection(jConn);
}
else
{
StringTokenizer st = new StringTokenizer(command,"ยง") ;
while (st.hasMoreTokens())
{
String token = st.nextToken().trim();
commandList.add(token);
System.out.println("String :"+token);
}
}
}
iterate(jConn,parameters,flag,commandList);

}
catch(IOException ioe)
{
System.out.println( "
" + "Exception in reading command line : " +ioe);

GDSLog.printLogNL( "
" + "Exception in reading command line : "+ioe);
}
catch(Exception e)
{
System.out.println( "
" +"Exception in reading command line or Error in Command : " +e);
e.printStackTrace();
}
}
}

private void iterate(JConnection jConn,
Properties parameters,
boolean flag,ArrayList commandList)
{
//ArrayList commandList = new ArrayList();
System.out.print("
"+"Enter Sabre Command (Type Q or E to Quit ) : ");
Iterator itr=commandList.iterator();
System.out.println("Size : "+commandList.size());
while(itr.hasNext())
{
String commandFinal =(String) itr.next();
dataSendReceive(jConn,commandFinal,parameters,flag,commandList);
System.out.println("Final :"+commandFinal);

}
}

   <<Less

Re: File IO !_NEWLINE_!pls answer urgent

Posted By:   Anonymous  
Posted On:   Tuesday, February 26, 2002 08:13 AM

And your question is???
About | Sitemap | Contact