Help coderanch get a
new server
by contributing to the fundraiser

Abhik Sarkar

Ranch Hand
+ Follow
since Jun 14, 2003
Merit badge: grant badges
For More
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 Abhik Sarkar

Hi Bhasker,

If it is only text, you can use the StringBuffer. Here is a modified version of my earlier example... you can see from the output that the execution time has reduced further.


20 years ago
Hi Bhasker,

My point was that using a BufferedWriter would improve the performance and that flushing too often slows things down. So, if you aren't using a BufferedWriter, you should definitely consider using it. Also, if you don't have a lot of content to write to the file, you could consider the possibility of putting everything into a StringBuffer before writing the entire StringBuffer to the file in one go.

You could look around on the internet for articles on improving performance. Here is one I came across on
Performance Tuning on Sun's Java site.

Hope this helps,
Abhik.
20 years ago
Hi Dheeraj,

I have come across the same requirement at times, and as far as I know it is not possible.

When I need this functionality very badly, I maint two collections. One in a Map and another in a list. When I need sequential access, I use the list, and when I need high speed access by key, I use the map.

Of course, one has to make sure that both collections are always sycn'ed.

I don't know whether this is the best approach, but it works for me.

HTH,
Abhik.
20 years ago
Right. I guess if you have lots of components, it is somekind of a form. If so, you might want to consider using the FormLayout from
JGoodies. It might take a while to learn it, but it is very likely that you would end up with relly neat forms.

Hope this helps,
Abhik.
20 years ago
Hi Rachel,

Based on the LayoutManager you have used, the components should automatically resize, when the frame is resized.

What Layout are you using?

Best regards,
Abhik.
20 years ago
Hi everyone,

I am having difficulty parsing a file which has variable syntax... any help would be apprciated.

Each "record" in the file has four columns. The first three are ascii, and the fourth is binary. The record separator is a newline character. The column separator is a comma.

As of now, I am using the newline character to separate records and it is largely successful. However, once in a while a newline creeps into the binary column, creating a bit of chaos. The position of the newline in the binary column is of course unpredictable. Column widths are also not fixed.

Any ideas how I could parse the file? Regexp, etc?

Many thanks,
Abhik.
[ June 27, 2004: Message edited by: Abhik Sarkar ]
20 years ago
Hi Bhaskar,

I hope you have a BufferWriter between your PrintWriter and the FileWriter. If not, putting that in would help immediately.

Also, if you have used the default constructor of the PrintWriter, then autoFlush is enabled. This means that each time you call println(), the stream will be flushed. I have written a small program to demonstrate the difference it makes. Please ignore that bad Exception handling... I just wanted to demontrate the difference.



Here is the output from some test runs...


As you can see, the process speeds up around 3 times! In you case, that could mean that the time taken reduces to around 20 minutes.

Whether or not you want the output to be flushed immediately depends on the nature of your application. If it doing batch processing, you could do away with frequent flushing... if it needs to display data in real-time, you need to flush frequently.

Hope this helps,
Abhik.
20 years ago
Hi,

I think you should be using something like the following instead:



(hope I got all the 's and the brackets right).

Alternately, you could also consider using the PreparedStatement (see API docs for more details).

HTH,

Abhik.
Hi Dhriti,

It will execute whatever is in the constructor :



of class A.

Hope this answers your question.

Best regards,
Abhik.
20 years ago
Hi Manoj,

Actually, it is just a matter of having a font which supports the Hindu Unicode characters. Even with JDK 1.3, you should be able to support display of Hindi characters if you set the font of the component to a Hindi Unicode supporting font (e.g. Devnagri).

Best regards,
Abhik.
20 years ago
Hi,

The usual method is to pass the enviroment variable to the application when invoking java by using the -D command line argument. You would do this in the script or batch file which sets up your enviroment and launches the applcation.

HTH,
Abhik.

Originally posted by Azriel Abramovich:
I am trying to access an enviroment variable from Java.
Meaning: I set (in Win2k) an enviroment variable:
My Computer -> Properties -> Advanced -> Enviroment Variables -> System Vars.

This does not reflect in System.getProperties()

Is there a way I can access that, or god forbid the registry?

In general I want to access a variable in a manner that will be platform independant.

Thanks!

20 years ago
Hi Everyone,

I have written a number of utilities in Java... some of them are only useful to my team at work, while others could be useful to anyone. Each tool uses some open source components (just uses, no modification). Each component might be distributed under a different license (GPL, LGPL, APL, Artistic etc.). What I am trying to understand is if there is any way I can be sure that I finally choose a correct license for my own application - Open Source or Proprietery.

Where can I find some write-up on how to license software that I write?

Many thanks,
Abhik.
20 years ago
Hi Everyone,

I have written a number of utilities in Java... some of them are only useful to my team at work, while others could be useful to anyone. Each tool uses some open source components (just uses, no modification). Each component might be distributed under a different license (GPL, LGPL, APL, Artistic etc.). What I am trying to understand is if there is any way I can be sure that I finally choose a correct license for my own application - Open Source or Proprietery.

Where can I find some write-up on how to license software that I write?

Many thanks,
Abhik.
20 years ago
According to the JavaDoc for DecimalFormat

The grouping separator is commonly used for thousands, but in some countries it separates ten-thousands. The grouping size is a constant number of digits between the grouping characters, such as 3 for 100,000,000 or 4 for 1,0000,0000. If you supply a pattern with multiple grouping characters, the interval between the last one and the end of the integer is the one that is used. So "#,##,###,####" == "######,####" == "##,####,####".


It would therefore seem that what you are trying (displaying in lacs) is not possible using the standard classes.
20 years ago
Rachel,
If you are creating and displaying your dialog in the construct method of the SwingWorker, maybe you could try to create the dialog in the construct and displaying it in the finished method.
HTH,
Abhik.
[ August 05, 2003: Message edited by: Abhik Sarkar ]
20 years ago