Ann Ron

Greenhorn
+ Follow
since Oct 21, 2003
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Ann Ron

Hi Jim,
I did understand what Michael had explained about filewriter and I did pass String variable to doSomething() and it prints in the log just fine.I am still coming across some errors which I think deal with scope issues but am not able to resolve it.I get an error f15 cannot be resolved but I dont know where else to declare it ,cuz f15 is actually calculated in the while block after getting it from the queue.

Thanks a lot for all the patience,I know I have tried quite a few people's.. Ann
18 years ago
I am sorry if u think i am trying to tell you how to do your job.I am not and I dont envy your position,dealing with so many questions..I am not second guessing anyone,if I sounded like that,I didn't mean to.
I know this is a forum running on goodwill and people helping out with what knowledge they r willing to share.I am just running short on time with my deadline and thought I cud post it at 2 places and get a response faster and then no one was responding anywhere so I got confused.
Thanks for your help and sorry for the wrong impression.
18 years ago
Hi,
I dont get this.....!!! Both my threads get closed in both the forums...
one place(I/O) says this is being addressed in another forum so they are closing this thread and in this other forum(Java Begginers),someone says they are moving this thread to (I/O) cuz it is too fancy for begginers forum..Will someone pl help me with this.pl check the other forum for responses before u go ahead and close threads...
18 years ago
Hi Jason,
I am restarting this thread since it wasn't addressed anywhere.I had posted this topic on the General forum since no one had responded here and someone moved it to the IO forum.and you closed it in this forum assuming it was being addressed there.Can you reopen this topic for discussion.I would really appreciate it if someone could help me with my Java problem.
Thanks,
Ann
****************************************************************
Hi,
I am writing a Java program which reads messages off of a queue and then formats the data and has to store this data in a text file,whenever my program runs it has to append to the text file already opened for that week and then it has to close this text file at the end of the week say on sunday nite @ 12.00pm and reopen a new text file @ 12.01am monday and start writing and appending to that file for that whole week and so on..
Any idea how to do this?
Any help appreciated.
Thanks.
Ann
I am attaching a copy of my code I have worked on so far,I am not sure where to append the msgs coming off a queue.
***************************************************
public class MQGet
{
public static void main(String[] args)
{
MQQueueManager MQQueueManager;
boolean forever = true;
try
{
MQQueueManager qMgr = new MQQueueManager(mqManager);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
MQQueue mqQ = qMgr.accessQueue(mqQname, openOptions);
MQMessage retrievedMessage = new MQMessage();
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = MQC.MQGMO_WAIT | MQC.MQGMO_FAIL_IF_QUIESCING
| MQC.MQGMO_NO_SYNCPOINT | MQC.MQGMO_ACCEPT_TRUNCATED_MSG;
gmo.waitInterval = 10000;
while (forever)
{
String outString = "";
int msgLen = 0;
retrievedMessage.messageId = MQC.MQMI_NONE;
retrievedMessage.correlationId = MQC.MQCI_NONE;
mqQ.get(retrievedMessage, gmo);
msgLen = retrievedMessage.getMessageLength();
outString = retrievedMessage.readString(msgLen);
System.out.println(msgLen);
if (retrievedMessage.getMessageLength() != 0)
{
String f0 = outString.substring(0,8);
String f1 = outString.substring(8,14);
String f14 = outString.substring(67,(msgLen+1));
f15 = fo + f1 + f14;
System.out.println(f15);
}
else
{
System.out.println(" No Messages available on Queue ");
}
class OpenSundayTextFile
{
FileWriter fw;
public OpenSundayTextFile() throws IOException
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Calendar cal = Calendar.getInstance();
if(cal.get(Calendar.DAY_OF_WEEK) == 1)cal.add(Calendar.DATE,-7);
cal.add(Calendar.DATE,-cal.get(Calendar.DAY_OF_WEEK)+2);
String fileName = sdf.format(cal.getTime()) + ".txt";
fw = new FileWriter(fileName,true);
doSomething();
goodBye();
}
public void doSomething() throws IOException
{
fw.write("f15\r\n");
}
public void goodBye() throws IOException
{
fw.close();
System.exit(0);
}
//This line gives me an error : syntax error on new//
new OpenSundayTextFile();
}
}
mqQ.close();
qMgr.disconnect();
}
*****************
Thanks in adavance
Ann

--------------------------------------------------------------------------------
Posts: 20 | Registered: Oct 2003 | IP: Logged

jason adam
Chicken Farmer (bartender)
Member # 13166
posted December 05, 2003 12:31 PM
--------------------------------------------------------------------------------
Closing this thread since it is being addressed in another one.
--------------------
Oh the cow in the meadow goes "moo"
Oh the cow in the meadow goes "moo"
Then the farmer hits him on the head and grinds him up
And that's how we get hamburgers.
Nowwwww chickens!
18 years ago
I was re-reading my code nad found some copy-paste mistakes,this is the correct code..
if (retrievedMessage.getMessageLength() != 0)
{
String f0 = outString.substring(0,8);
String f1 = outString.substring(8,14);
String f14 = outString.substring(67,(msgLen+1));
//this is a change
String f15 = fo + f1 + f14;
System.out.println(f15);
}
else
{
System.out.println(" No Messages available on Queue ");
}
class OpenSundayTextFile
{
FileWriter fw;
public OpenSundayTextFile() throws IOException
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Calendar cal = Calendar.getInstance();
if(cal.get(Calendar.DAY_OF_WEEK) == 1)cal.add(Calendar.DATE,-7);
cal.add(Calendar.DATE,-cal.get(Calendar.DAY_OF_WEEK)+2);
String fileName = sdf.format(cal.getTime()) + ".txt";
fw = new FileWriter(fileName,true);
doSomething();
goodBye();
}
public void doSomething() throws IOException
{
//this is a change
fw.write("f15\r\n");
}
public void goodBye() throws IOException
{
fw.close();
System.exit(0);
}
//This line gives me an error : syntax error on new//
new OpenSundayTextFile();
}
}
mqQ.close();
qMgr.disconnect();
}
18 years ago
Hi,
I am writing a Java program which reads messages off of a queue and then formats the data and has to store this data in a text file,whenever my program runs it has to append to the text file already opened for that week and then it has to close this text file at the end of the week say on sunday nite @ 12.00pm and reopen a new text file @ 12.01am monday and start writing and appending to that file for that whole week and so on..
Any idea how to do this?
Any help appreciated.
Thanks.
Ann
I am attaching a copy of my code I have worked on so far,I am not sure where to append the msgs coming off a queue.
***************************************************
public class MQGet
{
public static void main(String[] args)
{
MQQueueManager MQQueueManager;
boolean forever = true;
try
{
MQQueueManager qMgr = new MQQueueManager(mqManager);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
MQQueue mqQ = qMgr.accessQueue(mqQname, openOptions);
MQMessage retrievedMessage = new MQMessage();
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = MQC.MQGMO_WAIT | MQC.MQGMO_FAIL_IF_QUIESCING
| MQC.MQGMO_NO_SYNCPOINT | MQC.MQGMO_ACCEPT_TRUNCATED_MSG;
gmo.waitInterval = 10000;
while (forever)
{
String outString = "";
int msgLen = 0;
retrievedMessage.messageId = MQC.MQMI_NONE;
retrievedMessage.correlationId = MQC.MQCI_NONE;
mqQ.get(retrievedMessage, gmo);
msgLen = retrievedMessage.getMessageLength();
outString = retrievedMessage.readString(msgLen);
System.out.println(msgLen);
if (retrievedMessage.getMessageLength() != 0)
{
String f0 = outString.substring(0,8);
String f1 = outString.substring(8,14);
String f14 = outString.substring(67,(msgLen+1));
f15 = fo + f1 + f14;
System.out.println(f15);
}
else
{
System.out.println(" No Messages available on Queue ");
}
class OpenSundayTextFile
{
FileWriter fw;
public OpenSundayTextFile() throws IOException
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Calendar cal = Calendar.getInstance();
if(cal.get(Calendar.DAY_OF_WEEK) == 1)cal.add(Calendar.DATE,-7);
cal.add(Calendar.DATE,-cal.get(Calendar.DAY_OF_WEEK)+2);
String fileName = sdf.format(cal.getTime()) + ".txt";
fw = new FileWriter(fileName,true);
doSomething();
goodBye();
}
public void doSomething() throws IOException
{
fw.write("f15\r\n");
}
public void goodBye() throws IOException
{
fw.close();
System.exit(0);
}
//This line gives me an error : syntax error on new//
new OpenSundayTextFile();
}
}
mqQ.close();
qMgr.disconnect();
}
*****************
Thanks in adavance
Ann
18 years ago
Hi Michael,
I am kinda lost with my code.I am trying to get msgs off a queue like I mentioned in my last post but I need to write these msgs into a text file as they come as there can be a lot of msgs on the queue for which I do a MqQ.Get() till all the messages are taken off the queue.This code gets fired again when msgs come onto the queue.Now I am attaching part of my code.Please help me with how to append to the text file after every MQ read and where do I put that code in.
Thanks,
Ann
********************************************************
public class MQGet
{
public static void main(String[] args)
{
MQQueueManager MQQueueManager;
boolean forever = true;
try
{
MQQueueManager qMgr = new MQQueueManager(mqManager);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
MQQueue mqQ = qMgr.accessQueue(mqQname, openOptions);
MQMessage retrievedMessage = new MQMessage();
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.options = MQC.MQGMO_WAIT | MQC.MQGMO_FAIL_IF_QUIESCING
| MQC.MQGMO_NO_SYNCPOINT | MQC.MQGMO_ACCEPT_TRUNCATED_MSG;
gmo.waitInterval = 10000;
while (forever)
{
String outString = "";
int msgLen = 0;
retrievedMessage.messageId = MQC.MQMI_NONE;
retrievedMessage.correlationId = MQC.MQCI_NONE;
mqQ.get(retrievedMessage, gmo);
msgLen = retrievedMessage.getMessageLength();
outString = retrievedMessage.readString(msgLen);
System.out.println(msgLen);
if (retrievedMessage.getMessageLength() != 0)
{
String f0 = outString.substring(0,8);
String f1 = outString.substring(8,14);
String f14 = outString.substring(67,(msgLen+1));
System.out.println(f14);
}
else
{
System.out.println(" No Messages available on Queue ");
}
class OpenSundayTextFile
{
FileWriter fw;
public OpenSundayTextFile() throws IOException
{
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
Calendar cal = Calendar.getInstance();
if(cal.get(Calendar.DAY_OF_WEEK) == 1)cal.add(Calendar.DATE,-7);
cal.add(Calendar.DATE,-cal.get(Calendar.DAY_OF_WEEK)+2);
String fileName = sdf.format(cal.getTime()) + ".txt";
fw = new FileWriter(fileName,true);
doSomething();
goodBye();
}
public void doSomething() throws IOException
{
fw.write("hello world\r\n");
}
public void goodBye() throws IOException
{
fw.close();
System.exit(0);
}
//This line gives me an error : syntax error on new//
new OpenSundayTextFile();
}
}
mqQ.close();
qMgr.disconnect();
}
18 years ago
That was it!! Thanks a lot...for your help.
Ann
18 years ago
Hi,
It already extends JTabbedPane.cant we make it extend two saperate classes...?I am sorry for asking such novice questions..
public class TexturedTabbedPane extends JTabbedPane implements SelectableTexturedComponent, BackgroundTexturedComponent.
Thanks..
18 years ago
I am pasting the whole TexturedComponentUtil class here.
******************************************************
package fr.ui;
import java.awt.*;
import javax.swing.*;

public final class TextureComponentUtil {
/**
* Tiles a texture across a range
* @param g the graphics object used for drawing
* @param component the component that needs to be drawn
* @param bgImage the texture
* @param x1 the starting x location, which may be negative
* @param y1 the starting y location, which may be negative
* @param x2 the ending x location, which must be larger than x1
* @param y2 the ending y location, which must be larger than y2
*/
public static final void drawTexturedBackground(Graphics g, Component component, Image bgImage, int x1, int y1, int x2, int y2) {
if (g == null || component == null || bgImage == null) {throw new NullPointerException();}
if (x2 < x1 || y2 < y1) {return;}
int imageWidth = bgImage.getWidth(component), imageHeight = bgImage.getHeight(component);
// the number of complete rows and columns
int numX = (x2-x1)/imageWidth;
int numY = (y2-y1)/imageWidth;
// start at left
int drawX = x1;
// get everything across until the last incomplete column
for (int x = 0; x<numX; x++) {
// start at top
int drawY = y1;
for (int y=0; y<numY; y++) {
g.drawImage(bgImage, drawX, drawY, component);
// move down one space
drawY += imageHeight;
}
// this completes the column
g.drawImage(bgImage, drawX, drawY, drawX+imageWidth, y2, 0,0, imageWidth, y2-drawY, component);
drawX += imageWidth;
}
// get the last column except for the last little box
int drawY = y1;
for (int y=0; y<numY; y++) {
g.drawImage(bgImage, drawX, drawY, x2, drawY+imageHeight, 0, 0, x2-drawX, imageHeight, component);
drawY+= imageHeight;
}
// now draw whatever is leftover, which is smaller than one texture unit
g.drawImage(bgImage, drawX, drawY, x2, y2, 0, 0, x2-drawX, y2-drawY, component);
}
/**
* Tiles a texture across a range
* @param g the graphics object used for drawing
* @param component the component that needs to be drawn
* @param bgImage the texture
*/
public static final void drawTexturedBackground(Graphics g, JComponent component, Image bgImage) {
drawTexturedBackground(g, component, bgImage, 0, 0, component.getWidth(), component.getHeight());
}
}
18 years ago
What do you mean by validate the signature??? will that resolve my error?
18 years ago
That did remove my scope error but I am not sure what exactly you mean by upcasting the object passed to drawTexturedBackground to TexturedTabbedPane.
I now get another error on the preceding line of code : TextureComponentUtil.drawTexturedBackground namely,the method drawTexturedBackground() in the type fr.ui.TexturedComponentUtil() is not applicable for the arguments....
I am sorry if this is a really basic question,I am still learning Java and new to a lot of aspects...
Thanks a lot for your help.
Ann
18 years ago
Hi,
I have inherited this program from someone who left our organisation and this java code was written in visual age for java.We are trying to re-compile it all in Websphere now and I am getting this error when I compile the code in WebSphere.I know this has to do with the issue of scope but as far as I can see,I have imported the package it needs.Can anyone help me with this.Thanks in advance.
Ann
******************************************************
package fr.query.ui;
import javax.swing.plaf.*;
import javax.swing.*;
import java.awt.*;
import fr.ui.*;
import fr.query.cntl.*;
import java.util.*;
public class QueryTabbedPane
extends TexturedTabbedPane
implements Blinker, MessageDisplayCollection
{
private boolean day = true;
private final Vector blinkers = new Vector();
protected class QueryTabbedPaneUI
extends TexturedTabbedPane.TexturedTabbedPaneUI
{
protected void paintTabBackground(Graphics g,int tabPlacement,
int tabIndex,int x,int y,int w,int h,
boolean isSelected)
{
super.paintTabBackground(g,tabPlacement,tabIndex,x,y,w,h,
isSelected);
if (blinkers.contains(getComponentAt(tabIndex)))
{
Image currentTexture = day ? MESSAGE_LISTS_BLINK_TEXTURE_DAY: MESSAGE_LISTS_BLINK_TEXTURE_NIGHT;
if (getTextured() && currentTexture != null)
{
TextureComponentUtil.drawTexturedBackground
(g,TexturedTabbedPane.this, currentTexture,
x, y, x + w, y + h);
/*I get an error on this line ,saying,No enclosing instance of type
fr.ui.TexturedTabbedPane is accesible in scope.*/
}
}
}
18 years ago
Hi,
I am writing this code and getting an error : java.lang.StringIndexOutOfBoundsException: String index out of range: -70
This is my code snippet,Any idea how I solve this one..
************************************************************
String outstring = "123";
String repid;
String incno;
int MessageLength = MQ_Message.getMessageLength( );
outString = MQ_Message.readString(MessageLength);
repid = outString.substring(83,13);
incno = outString.substring(96,9);
**************************************************
Thanks in advance
Ann
18 years ago
That solved it.I now get a 13 digit long repstr.
Thanks a tonne,for all your help and patience.
Ann
18 years ago