• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using BufferedReader and StringTokenizer to delete numericals in a text file

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

i was wondering: does anybody have an idea whether or not this is possible:
I have a text file, of which i read the contents with BufferedReader and FileReader, with many trivia questions, which i got from someone i know. I am trying to write a trivia game with these questions.

The problem is, the file looks as follows (i will paste a small part of the contents on here:



etc etc.

I was wondering, since the questions are seperated by a uniform delimiter ("*"), would it be possible to use StringTokenizer to delete the numbers in brackets in front of every question and drag the words back, e.g.:

Cryptic Musica: Dumbass with freaky hair.*Daft Punk*Cryptic Musica: Dido is grateful.*Thank you*Cryptic Musica: Peter could be an angel.*Peter Gabriel*etc...etc...etc...

what do you guys think because im stumped!

klaas
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Having seen your previous posts, I am thinking this is part of a homework assignment, so I'll be careful to leave the work to you. You can't edit a file in place using a File/BufferedReader. You can do so with a RandomAccessFile but you would end up with a file larger than the data.
You don't tell us what your requirements are. Do you want to do a one-time conversion of the file and discard the old one? Do you want to read the file into a data structure your program can use?
In any case, start with the Java Tutorial chapter on Input/Output. A good foundation in the basics will save you many questions down the road.
reply
    Bookmark Topic Watch Topic
  • New Topic