Results 1 to 4 of 4
Like Tree1Likes
  • 1 Post By KevinWorkman

Thread: line length?

  1. #1
    chins4tw is offline Member
    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0

    Default line length?

    hello im currently doing a project that needs you to have a maximum 35 characters per line and im not sure how to do it this is what i have so far if someone could help me or direct me to where i can learn how to do this it will be helpful

    this is my code

    package ch12ex7;
    import java.io.BufferedReader;
    import java.io.FileReader;
    import java.io.IOException;
    import java.util.Scanner;
    public class Ch12Ex7 {
    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    String Line;
    String[] wordList;
    Scanner input = new Scanner(System.in);
    int number;System.out.print("Please enter the line limit you want: ");number=input.nextInt();
    try{
    BufferedReader ReadFile;
    ReadFile = new BufferedReader(new FileReader("word2.txt"));
    while((Line=ReadFile.readLine())!=null)

    {
    for(int i = 0; i < Line.length(); i++) {
    char c = Line.charAt(i);}

    Line=Line.replaceAll("\\<p\\>","\n");
    Line=Line.replaceAll("\\<br\\>","\n\n");
    Line=Line.replaceAll("\\<hr\\>","-----------------------------------");
    System.out.print(Line);

    }ReadFile.close();
    }catch(IOException e){System.out.println("Error " + e);}
    }}



    my file is
    JUNE BUGS<p>June bugs RAM in megabytes of fleshy fruit,<br>downsize fine fat
    figs<br>chip away at melon bits.<br>They monitor windows for open screens,<br>seeking
    felicity in electricity.<br>Built-in memory warns of websites<br>hiding spiders
    with sly designs.<br>Scrolling the scene of leaves and trees,<br>they network the
    neighborhood in flashy green jackets,<br>each bug a browser, scanner, looter-
    <br>not even knowing the word "computer."<p>by Avis Harley<p><hr>

    yes this is homework but i cant find the answer in my textbook

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,889
    Rep Power
    8

    Default Re: line length?

    Quote Originally Posted by chins4tw View Post
    yes this is homework but i cant find the answer in my textbook
    With programming, you aren't going to just find an answer in a book. You have to think through the problem, break it down into smaller pieces, and apply what you've learned to each individual piece.

    What does your program do? What exact piece are you stuck on?
    jim829 likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    chins4tw is offline Member
    Join Date
    Jun 2013
    Posts
    3
    Rep Power
    0

    Default Re: line length?

    Quote Originally Posted by KevinWorkman View Post
    With programming, you aren't going to just find an answer in a book. You have to think through the problem, break it down into smaller pieces, and apply what you've learned to each individual piece.

    What does your program do? What exact piece are you stuck on?
    My program shows a html file
    I need help limiting the character number to what i type in per line

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,889
    Rep Power
    8

    Default Re: line length?

    What have you tried so far? What exactly are you confused about?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Length of an Array: length() or just length ?
    By Jack_Tauson_Sr in forum New To Java
    Replies: 8
    Last Post: 03-18-2013, 08:16 PM
  2. Replies: 16
    Last Post: 09-17-2011, 02:41 AM
  3. Difference between length() and length
    By mitra in forum New To Java
    Replies: 7
    Last Post: 07-28-2011, 12:46 AM
  4. Can we set max line length, using iText library?
    By new_2_java in forum New To Java
    Replies: 0
    Last Post: 05-13-2011, 08:58 PM
  5. Maximum length of Command Line Argument
    By balamurugan.murthy in forum Advanced Java
    Replies: 11
    Last Post: 05-21-2010, 04:45 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •