Fix bad file name print-out,

Improve exeption handling,
Add BufferedInputStream support for file reading.
This commit is contained in:
giberta1 2002-04-15 10:46:14 +00:00
parent 271c6a6f9e
commit 61209c439c

View File

@ -1,7 +1,7 @@
// $RCSfile: MQSLoad.java,v $
// $Revision: 1.1 $
// $Revision: 1.2 $
// $Name: $
// $Date: 2001/07/12 09:57:24 $
// $Date: 2002/04/15 10:46:14 $
// $Author: giberta1 $
/*
@ -51,31 +51,37 @@ public class MQSLoad
private void MQSInit()
private void MQSInit() throws Exception
{
try
{
QMng = new MQQueueManager( QMng_Name);
System.out.println( "QManager Open: (" + QMng + ") !");
}
catch( Exception Expt)
{
throw Expt;
}
try
{
MsgQ = QMng.accessQueue( MsgQ_Name, MsgQ_Open_Options, null, null, null);
System.out.println( "MsgQ Open: (" + MsgQ + ") !");
}
catch(MQException MQ_Expt)
catch( Exception Expt)
{
System.out.println( "MQ/Series Exception: (" + MQ_Expt + ") !");
}
QMng.disconnect();
System.out.println( "QManager Close: (" + QMng + ") !");
catch(Exception Expt)
{
System.out.println( "JAVA IO Exception: (" + Expt + ") !");
Expt.printStackTrace();
throw Expt;
}
}
private void MQSDeInit()
private void MQSDeInit() throws Exception
{
try
{
@ -85,21 +91,15 @@ public class MQSLoad
System.out.println( "QManager Close: (" + QMng + ") !");
}
catch(MQException MQ_Expt)
catch( Exception Expt)
{
System.out.println( "MQ/Series Exception: (" + MQ_Expt + ") !");
}
catch(Exception Expt)
{
System.out.println( "JAVA IO Exception: (" + Expt + ") !");
Expt.printStackTrace();
throw Expt;
}
}
private void MQSPut_Msg( MQMessage Msg)
private void MQSPut_Msg( MQMessage Msg) throws Exception
{
try
{
@ -107,29 +107,24 @@ public class MQSLoad
MsgQ.put( Msg, pmo);
}
catch( MQException MQ_Expt)
catch( Exception Expt)
{
System.out.println( "MQ/Series Exception: (" + MQ_Expt + ") !");
}
catch(Exception Expt)
{
System.out.println( "JAVA IO Exception: (" + Expt + ") !");
Expt.printStackTrace();
throw Expt;
}
}
public MQSLoad( String args[])
{
try
{
byte input_char;
int msg_nb = 0;
MQMessage output_msg = new MQMessage();
try
{
if( args.length != 2)
{
System.out.println( "Usage: MQSLoad <Output_MsgQueue_Name> <Input_File_Name>");
@ -141,14 +136,19 @@ public class MQSLoad
MsgQ_Name = args[0];
File_Name = args[1];
System.out.println( "Output MsgQueue Name: (" + File_Name + ") Input File Name: (" + File_Name + ")");
System.out.println( "Output MsgQueue Name: (" + MsgQ_Name + ") Input File Name: (" + File_Name + ")");
MQSInit();
try
{
output_msg.format = MQC.MQFMT_STRING;
InputStream input_file = new FileInputStream(File_Name);
BufferedInputStream input_file = new BufferedInputStream( new FileInputStream(File_Name));
try
{
System.out.println("Input File Open: (" + input_file + ") !");
while( ( input_char = (byte)input_file.read()) != -1)
@ -179,6 +179,22 @@ public class MQSLoad
}
}
}
}
catch( Exception Expt)
{
input_file.close();
throw Expt;
}
input_file.close();
}
catch( Exception Expt)
{
MQSDeInit();
throw Expt;
}
MQSDeInit();
System.out.println( "MQS Load Completed !");
@ -187,7 +203,7 @@ public class MQSLoad
catch( Exception Expt)
{
System.out.println("JAVA IO Exception: (" + Expt + ") !");
System.out.println("Exception: (" + Expt + ") !");
Expt.printStackTrace();
}
}