• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

read a file ?

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am trying to develop a small application. I have a set of questions in a file and i need to read these from the file, as question by question an dneed to display them on the screen at the same time. I? am quite new to this. Can someone please help.
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Step to develop your program.

1. read all data in file.
2. Parse all data in to some Bean class to display and keep bean in List/Vector.
3. Display all data in List/Vector to screen/UI.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Example Read data in File

 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sam,
You can also search old posts, which are related to file accessing, using the keyword "file" in this forum...

I do believe some old posts are pretty useful for us to get to know about the things that we are willing to know...

Hope it helps...
 
sam robert
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks guys ...but i am still not clear as to how do i store the read part in a vector ....please explain that ....i appreciate it....
 
Ranch Hand
Posts: 8946
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you want to display the read question on the screen at the same time , why do you need a vector. You could print the read question immediately without requiring any temporaty storage.
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by sam robert:
thanks guys ...but i am still not clear as to how do i store the read part in a vector ....please explain that ....i appreciate it....



sam, if you want to keep all the lines in a vector, you can modify somkit's code as the following... As Pradeep mentioned, if you are directly printing the contents of the file to the console screen, you don't need a vector to store them... But if you want to use them in the future, you might need it...



Hope it helps...
 
I didn't do it. You can't prove it. Nobody saw me. The sheep are lying! This tiny ad is my witness!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic