Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • 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: 63804
209
  • 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.
 
Hey! Wanna see my flashlight? It looks like this tiny ad:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!