Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!

Chris Mathews

Ranch Hand
+ Follow
since Jan 08, 2001
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 Chris Mathews

Thanks Jim for reply.
I am running this code on NT.
Directories are already there and C and D are both local drive and definitely I have the access to these directories.
Copying byte by byte is very slow process esp. when you have large file.But it works !
Thanks anyway.
I am looking for some other alternative.
19 years ago
Is it so ?
I am not aware of this limitation.
If what you are telling is true then I understand why renaming to a different directory is failing time and time again.
Can somebody provide me more input, please ?
19 years ago
I am puzzled why this rename code is not working.I am able to rename a file within the same directory but when I want to rename a file of a directory to a different name and move to a different directory then it is not working.
Can you tell me why ?
Is the naming convention of directories wrong ?
Your help is well appreciated.
19 years ago
Could not understand the messages :
When I used -Xmx option like :
java -Xmx 256M Test
I got the following message :
Incompatible initial and maximum heap sizes specified:
initial size: 1048576 bytes, maximum size: 0 bytes
The initial heap size must be less than or equal to the maximum heap size.
The default initial and maximum heap sizes are 1048576 and 67108864 bytes.
Could not create the Java virtual machine.
When I used -Xms option like
java -Xms 256M Test
I got the following message :
The specified initial heap size is too small. (262144 bytes required.)
Could not create the Java virtual machine.

I don't know how to increase the size of VM . Any link to get more info on these ?
Am I doing something wrong here ?
19 years ago
OutofMemoryError :
Reading from a file and writing to a file :

Input File(input.txt) is like this :
5575421,CNN,65431
5575422,FOX,65432
5575423,CNN,65433
5575424,CNN,65434
5575425,CNN,65435
5575426,CNN,65436
5575421,CNN,65437
5575422,FOX,65438
5575423,CNN,65439
5575424,USA,65440
The output will contain the following :
1. The total Number of records in the input file -- in the above example it will be 10.
2.The number of unique values in the first column -- in this case 6.
3. The number of unique values in the second column -- In this case it will be 3 (CNN,FOX and USA).
This is what my code look like :


--------------------------------------------------------------------------------
This is working just fine but when number of records (say 1 Billion or so) then it crashes saying 'OutofMemoryError'.
Can this be prevented from happening ?
How can I increase the VM size ? What is -Xms and -Xmx options ?
What is the better option to handle such a large file ?

Your input is appreciated.
Thanks.
19 years ago
I realized that problem is in some other method.
Here is what this method is supposed to do :
Input File(input.txt) is like this :
5575421,CNN,65431
5575422,FOX,65432
5575423,CNN,65433
5575424,CNN,65434
5575425,CNN,65435
5575426,CNN,65436
5575421,CNN,65437
5575422,FOX,65438
5575423,CNN,65439
5575424,USA,65440
The output will contain the following :
1. The total Number of records in the input file -- in the above example it will be 10.
2.The number of unique values in the first column -- in this case 6.
3. The number of unique values in the second column -- In this case it will be 3 (CNN,FOX and USA).
This is what my code look like :

This is working just fine as I said in my previous post but when input file has large number of records (say 1 Billion or so) then it crashes saying 'OutofMemoryError'.
So where is the memory leak ? what is the better option to handle such a large file ?
Your input is appreciated.
Thanks.
[ edited to correct code formatting -ds ]
[ August 07, 2002: Message edited by: Dirk Schreckmann ]
19 years ago
Hello,
I am writing a java program which, in nut shell, reads from a file and write to a file.
The input file is like this :
Bush is the President of USA.
5
then the output file will have
Bush is the President of USA.
Bush is the President of USA.
Bush is the President of USA.
Bush is the President of USA.
Bush is the President of USA.
Basically it will repeat the first line the number of times defined in the second line of the input file.(like 5 in the above example)
The program is working just fine.But I now I have noticed a problem.The problem is when the number of iteration is a very high number -- like let's say
1000,000,000 (=1 billion).
It gives an error which says
Exception in thread "main"
java.lang.outofmemoryerror.
How should I handle this outofmemory error.
Your input will be quite appreciated.
Thanks.
19 years ago
I am trying to write .dat file to run java program. In my dat file there is just one line 'java abc'. It is double clickable and it works just fine.This way, the user don't have to go through MS Dos promt and then write 'java abc'. So I wrote .dat file in which there is just this statement.My question is that when I double click it runs and does everything that is expected of that program but this program also gives some message on the command line that I can't see because .dat file after clicking closed very fast.When I run through MS-DOS I can see the command line message but through .dat file I can't .I wanted to know is there a way by which I can make sure that that after clicking the .dat file it remains open for certain time (let's say 1 minute) so that one can see the message and go from there.
If there is anybody who has worked with '.dat' file before, must be knowing what I am talking about and how to resolve this problem.So please help me.
Thanks,
Chris.
I am trying to write .bat file to run java program. In my bat file there is just one line 'java abc'. It is double clickable and it works just fine.This way, the user don't have to go through MS DOS promt and then write 'java abc'. So I wrote .bat file in which there is just this statement.My question is that when I double click it runs and does everything that is expected of that program but this program also gives some message on the command line that I can't see because .bat file after clicking closes very fast.When I run through MS-DOS I can see the command line message but through .bat file I can't .I wanted to know is there a way by which I can make sure that that after clicking the .bat file it remains open for certain time (let's say 1 minute) so that one can see the message and go from there.
If there is anybody who has worked with '.bat' file before, must be knowing what I am talking about and how to resolve this problem.So please help me.
Thanks,
Chris.
[This message has been edited by Chris Mathews (edited September 12, 2001).]
20 years ago
How can I make it return 1 or 2 depending upon what abc contains. If abc is just space(" ") or if abc is " 5 ".
What should I do?
What's wring with this code?

<code>
public class Test
{ public static void main(String args[])
{
String abc = " ";
System.out.println(abc.trim());

if ((abc.trim()) != null)
{abc = abc.trim();
System.out.println("its at 1" + abc);}
else
{ abc = "01";
System.out.println("its at 2 " + abc);}


}
}
</code>
I thought this would print 'its at 2' but No...it is printing 'its at 1'.....Why ?
Any insight?
I am reading a file.In some records it can have just spaces.It can be one space, two spaces or may be many more.I am trying to come up some kind of method where I will compare all of these spaces with just one sapce and I want this to be true.I mean for me one space or multiple space should mean the same thing.How can I do this?
trim() does not achieve what I want.
compare() also does not seem to work.
Any body has any idea?
How to represent int 1 as 0001?
I can represent 1 as 0001 using string concatenation. But does Java provide any method which will help me display int 1 as 01 or 00001 without using string concatenation? I am using with some numbers between 1 and 9999 and I want to represent all numbers in 4 bytes like as I said before 99 as 0099.How can I do that ?
Your help is appreciated.
Does Java provide any method which will arrange 'n' numbers in ascending or descending order ? Are you aware of any such method?
Your help is appreciated.
[This message has been edited by Chris Mathews (edited August 22, 2001).]
Is it possible to convert java classes into exe files so that even if JSDK is not installed in one's machine, one shoule be able to run ? Please let me know how this can be achieved .
Thanks.