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: Help..see the code and jst i need small help..

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help..see the code and jst i need small help..

    I would just like my string testline(name of string) to break when a $ symbol is pressd instead of new line..any edits...do it plzz...



    /*import java.util.Scanner;
    import java.util.regex.*;
    public class test
    {
    public static String s;
    public static void main(String args[])
    {
    int i,l,x=0;
    String a,c;
    String testline;
    Scanner br=new Scanner(System.in);
    testline=br.next();
    Pattern pattern = Pattern.compile("[0-1]+");
    Matcher matcher = pattern.matcher(testline);
    while (matcher.find()) {
    s=matcher.group();
    for(i=0;i<s.length();i=i+4)
    {
    c=s.substring(i,i+4);
    testline=binary(c,testline);
    }
    }
    testline=testline.replaceFirst("Input", "Output");
    System.out.print(testline);
    }
    public static String binary(String s,String testline)
    {
    int i = Integer.parseInt(s, 2);
    String t="";
    t=t.valueOf(i);
    //System.out.println(t);
    testline=testline.replace(s, t);

    return testline;
    }
    }
    */


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Help..see the code and jst i need small help..

    Welcome to the forum! Please read this topic to learn how to post code correctly.

    Review the String API for possible answers to your question.

  3. #3
    Member
    Join Date
    Oct 2013
    Location
    United Kingdom
    Posts
    62
    Thanks
    1
    Thanked 4 Times in 4 Posts

    Default Re: Help..see the code and jst i need small help..

    What exactly do you mean by string to break when a $ is pressd instead of new line? Is it while reading from keyboard or what is the scenario you are having?
    Thanks and regards,
    Sambit Swain

Similar Threads

  1. Small Problem with my Code
    By Cyril in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 20th, 2013, 03:02 AM
  2. Small problem in big code, not sure why
    By diesal11 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: October 16th, 2011, 10:25 AM
  3. WatchService - small code for monitoring folders
    By zincc in forum What's Wrong With My Code?
    Replies: 5
    Last Post: March 8th, 2011, 10:19 AM
  4. Replies: 2
    Last Post: August 1st, 2010, 06:29 AM
  5. Small Project
    By 3XiLED in forum Paid Java Projects
    Replies: 7
    Last Post: March 1st, 2010, 08:35 AM