Results 1 to 2 of 2
  1. #1
    technoreject is offline Member
    Join Date
    Jun 2011
    Posts
    9
    Rep Power
    0

    Default Need to find a way to print line spacing by words

    I have some PHP code echoing out on a website some updates which I will print, everything is on the first line (all the words, atleast) so I need no while statement reading through all of the lines, my problem is that I need to find a way that whenever Java finds the characters "<br>" to replace them with and if it can't find it to do it once more.
    Java Code:
    	    	    drawCenteredString(fontRenderer, stringtranslate.translateKey([Everything before that <br> and one more if there is no <br>]), width / 2, (height / 4 - 60) + xxx, 0xffffff);), width / 2, (height / 4 - 60) + xxx, 0xffffff);
    so if it reads:
    Java Code:
    Updates!<br>Update 1: This is update 1<br>Update 2: This is update 2
    it will do
    Java Code:
    	    drawCenteredString(fontRenderer, stringtranslate.translateKey("Updates!"), width / 2, (height / 4 - 60) + xxx, 0xffffff);
    	    drawCenteredString(fontRenderer, stringtranslate.translateKey("Update 1: this is update 1"), width / 2, (height / 4 - 60) + xxx+20, 0xffffff);
    	    drawCenteredString(fontRenderer, stringtranslate.translateKey("Update 2: this is update 2), width / 2, (height / 4 - 60) + xxx+40, 0xffffff);
    This is my current code:
    Java Code:
        	try{
            StringTranslate stringtranslate = StringTranslate.getInstance();
            drawDefaultBackground();
    		URL google = new URL("http://brettterrell.netai.net/test.php");
    		URLConnection yc = google.openConnection();
    		BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
    		String inputLine;
    		inputLine = in.readLine();
    		while(inputLine.indexOf("<br>") != -1){
    	    drawCenteredString(fontRenderer, stringtranslate.translateKey(inputLine), width / 2, (height / 4 - 60) + xxx, 0xffffff);
    	    xxx = xxx + 20;
    		}
    		in.close();
            super.drawScreen(i, j, f);
        	}
        	catch(Exception e){
      e.printStackTrace();[CODE]
    }
    }[/code]
    As you can probably see I got really stuck on my while statement :/

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    I need to find a way that whenever Java finds the characters "<br>" to replace them with and if it can't find it to do it once more.
    I can't understand what this says. When you find "<br>" you want to replace it with what?
    And if if cant' find it do it once more???
    Can you show an input line with the <br>s and the output lines you want created?

Similar Threads

  1. find the link between two words by using wordnet
    By STR in forum Advanced Java
    Replies: 8
    Last Post: 07-06-2011, 07:59 AM
  2. Replies: 3
    Last Post: 02-13-2011, 08:54 PM
  3. print every other line
    By welikedogs in forum New To Java
    Replies: 23
    Last Post: 11-16-2010, 05:40 PM
  4. print to the next line
    By bar in forum New To Java
    Replies: 14
    Last Post: 07-15-2010, 01:48 AM
  5. How to print words in different colours?
    By veen in forum New To Java
    Replies: 7
    Last Post: 06-10-2010, 04:54 PM

Posting Permissions

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