Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / Java help! (c users might be able to help too)

Author
Message
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 1st Mar 2004 04:11 Edited at: 1st Mar 2004 04:14
im trying to make a program in java (NOT java script) that takes a text file, takes out any "bad chars" (!@#$%^&*,;:'" etc) and makes it so it only has X amound of chars a line, and line breaks after each .
but for some reason it doesnt work:

infile:


outfile:


notice it doesnt add spaces in the right place, anyone have an idea why? source below



Great Knight
21
Years of Service
User Offline
Joined: 25th Feb 2003
Location:
Posted: 1st Mar 2004 04:41
I will take a look at it.

AMD Atherlon 2400+ XP, 380 DDr memeory, ATI Radeon 9000 64 DDR, Windos XP home edition.
-----------------------And a Katana.
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 1st Mar 2004 05:09
awsome, thanx a lot

JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 2nd Mar 2004 05:17
sorry, i know its only been a day, but i need this done. and i know there are at least 1 or 2 people here that know java...

The second smartest person in the world, as of TODAY!
JoelJ
21
Years of Service
User Offline
Joined: 8th Sep 2003
Location: UTAH
Posted: 2nd Mar 2004 06:04
FIXED IT...nm guys

The second smartest person in the world, as of TODAY!
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Mar 2004 13:29
Gotta give me time to read the forums.

The easiest way I can think of is to use fileReader, and read each line into a String. Then create a stringTokenizer using that string and break it up into seperate tokens using the delimiters(bad chars) you want. Consecutively add each new token to a temp string and keep track of the temp string's length. If adding the new token to the temp string creates a length longer than the line you want, write the current temp string to a string array then add that last token to an empty temp string. Continue the procedure until the file ends. Then write the string array out to a file.

"eureka" - Archimedes
Joe Cooning
21
Years of Service
User Offline
Joined: 29th Mar 2003
Location: United States
Posted: 3rd Mar 2004 17:35
Let me see if I can remember how to read from files. Ok...I can't remember.
Here's something.

This code removes stuff from a string, just send in a string. amybe that will help.

"The greatest oxymoron . . . ever, 'Microsoft Works'."

Login to post a reply

Server time is: 2024-09-21 12:07:24
Your offset time is: 2024-09-21 12:07:24