Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Java program to reduce spaces between the words in a text file

  1. #1
    Junior Member
    Join Date
    May 2009
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Java program to reduce spaces between the words in a text file

    Hi. i'm new to Java.
    Pls i need assistance on how to reduce spaces (which are more than one) between words in a text file .
    Thanks.


  2. #2
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: text file

    Hello tyolu and welcome to the Java Programming Forums

    You will need to read in the text file line by line and then re-write it out again.

    There is a tutorial for reading a file line by line here:

    http://www.javaprogrammingforums.com...ner-class.html

    Is the white space between words constant or does it change?

    You can use Regular Expressions and String replace.

    Let me know and I will help you with the code.
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: text file

    This post may also be of some help to you:

    http://www.javaprogrammingforums.com...text-file.html
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Text Processing with Regular Expressions explained in Java
    By JavaPF in forum Java Programming Tutorials
    Replies: 3
    Last Post: February 8th, 2022, 05:16 PM
  2. How to format text in java?
    By fourseven in forum Java Theory & Questions
    Replies: 3
    Last Post: May 16th, 2009, 09:42 PM
  3. [SOLVED] Enhancement in program of removing whitespace from text file
    By John in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: April 27th, 2009, 09:36 AM
  4. Problem in implementing mortgage calculator
    By American Raptor in forum AWT / Java Swing
    Replies: 1
    Last Post: April 1st, 2009, 02:09 PM

Tags for this Thread