• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

travel agent - outofmemory heap error  RSS feed

 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at java.lang.String.substring(String.java:1939)
at java.util.StringTokenizer.nextToken(StringTokenizer.java:335)
at lab6Ex1.main(lab6Ex1.java:81)
Java Result: 1



lab6Ex1




Travel.java



data in Travel_Records.txt:

0|S8470017G|Abhradeep Banerjee | Singapore |09/07/2007 | 13:28 | Kolkata, India | 09/01/2010 | 16:28
1|S22209619B|Debabrata Banerjee | Kolkata, India |09/08/2007 | 13:28 | Singapore| 09/01/2010 | 16:28
2|S8328944B|Debabrata Banerjee | Kolkata, India |09/08/2007 | 13:28 | Singapore | 09/01/2010 | 16:28
3|S8470017G|Abhradeep Banerjee | Singapore |09/07/2007 | 13:28 | Kolkata, India | 09/07/2007 | 16:28
4|S8470017G|Abhradeep Banerjee | Kolkata, India |09/08/2007 | 13:28 | Singapore| 09/08/2007 | 16:28






 
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I ran it, I did not get an out of memory error. I got an infinite loop.
I moved the br.readLine() to the while loop because you were not reading the next line in the loop.
Fixing this caused an error at the Integet.parseInt() method but that is another issue...
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured out the Integer.parseInt() problem. When I created the Travel_Records.txt file, I added a superfluous carriage return at the end of the file. Now the application prompts me with a list of commands but I do not know what to enter to reproduce the problem.
 
Tom Reilly
Rancher
Posts: 618
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

When I ran it, I did not get an out of memory error. I got an infinite loop.

Actually, had I been patient enough, I would have gotten the out of memory error but I recognized the problem before that happened.
 
Abhradeep Banerjee
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot man I got it working
for some reason when i run it on command prompt i get a file Text_Record.txt was not found but i dont get that error when i run it in netbeans
any reason why?

thanks
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably, In Netbeans it will start looking from current directory and get it.

In either case , you need set context path explicitly while using console.
 
Marshal
Posts: 60168
188
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use such long lines in code. They make the whole thread very difficult to read.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!