Isolating capitals in Strings, and altering the strings.

Dear CodeWizards,
My friend asked me to help him write some code for his website he's making. I'm a freshman in college, in elementary Java Programming, so I thought I could do it. Turns out I'm wrong, we haven't even touched on the stuff he wants me to do, and I would like your help if you could lend me a hand.
Here's what he emailed me:
"Hey Jason,
You're in that computer programming class, right? Well I am making this website, and it has some little games on it and stuff. Part of it I don't know how to figure out. I want the person to input a name of an organization. Then I want the program to take all the capital letters, and put asterisks around them, then re print what he person says with the asterisks in there, as well as with the rest of the letters capitalized. Then I want it to print out just the capital letters in the asterisks, like an acronym. Also if there is anything in Parenthesis, i want it disregarded. Heres an example:
What is the name? Midgets Riding UniCycles (How Fast Can They Go?)
The name is: *M*IDGETS *R*IDING *U*NI*C*YCLES
The Acronym is: MRUC
Thanks,
Jim"
Anyway fellas, I'm in over my head here. I was told by an upperclassman this should be easy, but what upperclassman is going to help out a freshman, lol. If someone has a spare moment and they could whip this up, then I would appreciate it. If not, any help would be great. I am without direction. Sorry for being such a newb... Thanks again guys'n'gals.
Jason

What have you managed to do so far?
Here's some general advice:
Read the assignment text well, send email to your instructor about the parts
that are not clear, and start doing it. Only when you encounter a problem that
you can't overcome by reading your notes, the Java tutorial, or the
documentation of standard classes come back here and ask a specific question
with a clear description of the problem you are having with some source code,
what you want it do, what it is doing instead, and possible error message.
Java tutorial: http://java.sun.com/docs/books/tutorial/
Documentation of standard classes: http://java.sun.com/j2se/1.5.0/docs/api/
Examples of how to use them: http://javaalmanac.com

Similar Messages

  • Converting a file to string and then, the string to a file

    I need to send a File (a JPG file) as String (inside a XML document).
    After this, i want to write the String representing the file (reading the XML document) as a File on my disk (making a JPG).
    Can anybody help me ???
    Thanks in advance !!

    I found this in the forum, the author was brianlmartino1
    and it works perfectly.
    Thank you !!
    import java.io.*;
    import org.apache.soap.encoding.soapenc.Base64;
    public class FileUtils {
    static public void main(String args[]) throws Exception {
    System.out.println("-- go !!!!");
    // get input binary source
    File file = new File("c:\\temp\\file.JPG");
    BufferedInputStream bis = new BufferedInputStream(new
    FileInputStream(file));
    int bytes = (int) file.length();
    byte[] buffer = new byte[bytes];
    int readBytes = bis.read(buffer);
    bis.close();
    // encode binary source
    String encodedString = Base64.encode(buffer);
    // decode String source and save the file to the disk
    byte[] buffer2=Base64.decode(encodedString);
    File file2 = new File("c:\\temp\\fileNew.jpg");
    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file2));
    bos.write(buffer2);
    bos.close();
    System.out.println("-- ready !!!!");
    }

  • Find a specific character in an input string and getting the string after if

    Hello,
    my requirement is as such, lets say we have an input string ABHISHEK #1234, or BOMBAY 123 #235,
    i need to find if the character string has # in it,, if yes pick all the numbers after # .
    in the above example, i need output as 1234 and 235
    and if any non numeric values after # set a flag
    please help me in this.
    regards
    Abhishek

    Hi Abhishek,
    This can be done in BODS using below settings in file format (only if your source is flat file):
    Below is the source file data :
    abcd#1234,Bombay#23456
    By using this file format setting, you should be able to get all the numbers in one column which you can use futher and you can verify this columns data by using "is_valid_int", not null function in BODS.
    I think it should give you solution.
    Thanks,
    Tanvi

  • Differnce between null string and an empty string??

    what is the major difference between null string and an empty string??
    I wrote the following simple program and I could see some different output.
    Other than that, any other differences that we should pay attention to???
    C:\>java TestCode
    Hello
    nullHello
    public class TestCode
         public static void main(String[] s)
         {     String s1 = "";
              String s2 = null;
              System.out.println(s1 + "Hello");
              System.out.println(s2 + "Hello");
    }

    There's a big difference between the two. A null String isn't pointing to an object, but an empty String is. For example, this is perfectly fine:
    public class TestCode
        public static void main(String[] args)
            String s = "";
            System.out.println(s.length());
    } It prints out 0 for the length of the String, just as it should. But this code will give you a NullPointerException:
    public class TestCode
        public static void main(String[] args)
            String s = null;
            System.out.println(s.length());
    } Since s isn't pointing to anything, you can't call its methods.

  • Day of year bug - format date/time string and scan from string?

    I've noticed that the day of year returned by "Format Date/Time String.vi" starts with a value of 1 for Jan-1 while "Scan from String.vi" wants a 0 index.  Is this a bug or feature?  
    (I'm using Labview 2010 Service Pack 1)

    I think the best idea is to use seconds since for your arithmetic, because it is going to be the most consistent and robust solution. Knowing that a day has 86400 seconds is all that is needed and you won't run in possible inconsistencies with date time implementations caused by our anything but logic calender. I would hazard that the functionality of converting a timestamp into year and day of year and back is impossible to make consistent without sacrificing other possibly conflicting transformation in the Timestamp into String and Timestamp from String manipulations.
    "Seconds since" being the actual base unit in all LabVIEW timestamps, it is best to do any arithmetic on it in this base unit.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Select-string and eliminate the file name of searched file

    Is there a way with the select-string command to exclude the file name of the file you are searching and still get the line items that match your results? 
    Similar to the DOS find command results.  I am trying to become completely independent of a DOS window and still have to find to reduce log files and make them easy to read.
    Thanks
    Chris
    Chris J.

    Sure.  Select-String returns MatchInfo objects, and the string value of the matched line is in the Line property of the objects.
    Select-String -Pattern 'text to match' -Path 'filename.ext' |
    Select -ExpandProperty Line
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • How do I convert a string, and use a string as a property?

    I have an array in the following format:
    {ownsCar: 'true', ownsBike: 'true', ownsHouse: 'true'}
    {ownsCar: 'false', ownsBike: 'true', ownsHouse: 'true'}
    {ownsCar: 'true', ownsBike: 'false', ownsHouse: 'true'}
    etc ............
    And I need to test against each item e.g.
    if...
    myDataGrid[myItem].ownsCar == Object(myCheckbox).label
    ... then
    if...
    myDataGrid[myItem].ownsBike == Object(myCheckbox).label
    ... then
    if...
    myDataGrid[myItem].ownsHouse == Object(myCheckbox).label
    ... then
    But I need to build my application where the property (e.g. "ownsCar", "ownsBike", "ownsHouse") is a variable such as:
    if...
    myDataGrid[myItem].myProperty == Object(myCheckbox).label
    ... then
    I would like to loop through my Array, counting the number of items, and then use each item as a property.
    How would I convert the string (e.g. "ownsCar") into a property "myProperty" ???
    Many thanks in advance
    Chris

    Thanks, but my problem is that I won't know what my property will be.
    E.g. they could be...
    {svnsdkvnsdklvnsdklv: 'true', seuAfnwfnw: 'true', asfwseionf: 'true', etc.................}
    and there could be lots of them.
    I need to have myObject[N], where N is a variable property for each of the items taken from a variable length array
    so...
    ownsCar is represented by myObject.[N]
    ownsHouse is represented by myObject.[N+1]
    ownsBike is represented by myObject.[N+2]
    etc
    (sorry, this is so difficult to explain when I dont know what the answer is)

  • Find one character in a string and count the amount of times its found

    Hey SQL Forum experts.
    I have a string that is about 3000 characters long.
    I'm trying to search my string for the value '{'.
    Then I want to count how many times this value is found.
    How do I form the Oracle SQL to do this?

    Hi Colin,
    Try the following:
    SQL> var s varchar2(100)
    SQL>
    SQL> exec :s := 'Colin {{ Mackenzie {{{'
    PL/SQL procedure successfully completed.
    SQL> select length(:s) - length(replace(:s, '{')) Matches from dual;
       MATCHES
             5
    SQL> exec :s := 'I have a string that is about 3000 characters long'
    PL/SQL procedure successfully completed.
    SQL> select length(:s) - length(replace(:s, '{')) Matches from dual;
       MATCHES
             0Regards.

  • Reading the XML file and displaying the string with the desired output

    Hi Gurus,
    I have an xml file as below.
    catalog>
    <book>
    <id>101</id>
    <genre>Computer</genre>
    <author>Jim Cortez</author>
    <title>XML for dummies</title>
    <price>44.95</price>
    <description>An in-depth look at creating mashed potatoes
    with XML.</description>
    </book>
    <book>
    <id>102</id>
    <author>George Bush</author>
    <title>I'm the decider</title>
    <genre>Fantasy</genre>
    <price>0.95</price>
    <description>I like milk and cookies.</description>
    </book>
    </catalog>
    I would like to display the Output as
    [<catalog>:1]
    [<book>:1]
    [<id>:1]
    [101:3]
    [</id>:2]
    [<genre>:1]
    [Computer:3]
    [</genre>:2]
    [<author>:1]
    [Jim Cortez:3]
    [</author>:2]
    [<title>:1]
    [XML for dummies:3]
    ............ etc., etc.,,
    here is the code template.......
    import java.io.*;
    class TagScanner implements TokenStream {
    public static final int BEGIN_TAG_TYPE = 1;
    public static final int END_TAG_TYPE = 2;
    public static final int TEXT_TYPE = 3;
    protected Reader reader = null;
    /** Lookahead char */
    protected char c;
    /** Text of currently matched token */
    protected StringBuffer text = new StringBuffer(100);
    public TagScanner(Reader reader) throws IOException {
    this.reader = reader;
    nextChar();
    protected void nextChar() throws IOException {
    c = (char)reader.read();
    public Token nextToken() throws IOException {
    if ( start of a tag ) {
    // scarf until end of tag
    // type is either BEGIN_TAG_TYPE or END_TAG_TYPE
    if ( end of file ) {
    type = Token.EOF_TYPE;
    text = "end-of-file";
    else {
    // scarf until start of a tag
    type = TEXT_TYPE;
    if ( just whitespace ) {
    // ignore and get another token
    return new Token(type, text.toString());
    Can someone please provide me the logic for the code please........... here is the complete link of the excersie
    http://www.antlr.org/wiki/display/CS652/Lexer+for+XML
    Many Thanks
    -M

    Can someone please provide me the logic for the code please..........The logic is pretty well spelled out for you in the description of the assignment and the outline for the code you provided. If you mean
    Can someone please do my homework for me....The answer to that is usually yes, someone can do your homework for you, but no, they usually won't actually do it for you.
    However, if you are really stuck on what to do, you should consider:
            if ( start of a tag ) {How would you know that you are at the start of a tag? Once you can answer that, the rest sort of works itself out as long as
                // scarf until end of tagyou realize what it means to 'scarf' and how to determine when an end-of-tag is reached (hint, very similar as to how to determine if you are at the start-of-tag).

  • Problem with Call Library Function. Want to pass a string and return a string, but my compiler does not recognize "CStr" and Labview does not recognize my "char *function()" callout

    Hi, I'm trying to use a .DLL I wrote in Visual C++ .NET. The Call Library Function generates a function prototype of "CStr Parser(CStr arg_raw)"
    but my compiler won't accept this. So I change it to how C normally deals with strings "char *Parser(char *arg_raw). Now the Call Librafy Function does not find "Parser" in my .DLL though it is definitely there!
    Help!
    -Fong

    Hello
    You will need to include extcode.h in your C file. You can find this under ..\LabVIEW\cintools folder.
    The include has all the defines you will need.
    Bilal Durrani
    NI
    Bilal Durrani
    NI

  • Finding multiple strings in a text file and deleting the entire line

    Get-Content c:\output-Copy.txt | Where-Object {$_ -notmatch 'something1', 'something2', 'something3', 'something4' } | Set-Content temp.txt
    Above is the program that when it has 1 argument in the -notmatch part will find the specific string and delete the entire line. I need to be able to use multiple strings for my search, I am totally drawing a blank on this and I know its something REALLY
    simple but my brain is fried. The above code will work IF i only leave 'something1' and delete the rest. I need to find MULTIPLE matches and remove them all at once, what is a good way to accomplish this.

    You can use an alternating regex, like this:
    Get-Content c:\output-Copy.txt |
    Where-Object {$_ -notmatch 'something1|something2|something3|something4' } |
    Set-Content temp.txt
    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

  • What Are the Differences Between String and StringBuffer?

    Both String and StringBuffer are final classes. StringBuffer grows in size dynamically. Could people help to detail other differences between String and StringBuffer?

    String is immutable. In other words, once it is made, the contents of that instance of String cannot be changed (easily). The size and characters cannot be changed, and code can take advantage of this fact to optimize space. Also, once you have a reference to a string, you do not need to worry about it changing at all, so you can eliminate constant tests to verify things such as size in another class that may want to hold onto the string.
    StringBuffer, as you noticed, can change dynamically. While this provides flexibility, it cannot be optimized and assumptions cannot be made as with strings. If a class holds a reference to a StringBuffer that it does not own, there is a possibility that it may change things such as size when the class tries to use it later. StringBuffer is also less efficient in handling space then an equivalent String. The character array to hold a String is exactly the length to hold all the characters. StringBuffer, on the other hand, adds a 16 character buffer of array space for possible expansions. Also, the size of the internal array doubles when its internal capacity is exceeded. So, unless you explicitly maintain the size, a StringBuffer will take up more memory then an equivalent String, and if your program needs thousands of instances of Strings (which is not uncommon), that space can add up.
    I hope this helps clarify some things for you.
    -JBoeing

  • How to execute a string formula and assign the result to a number field

    How to execute a string formula and assign the result to a number field
    Hi,
    we have a function that returns a string like this:
    '(45+22)*78/23'
    After we should calculate this string and assign the value to a numeric block field
    Example:
    k number(16,3);
    k:=fun1('(45+22)*78/23'); where fun1 execute and translate to number the string.
    Does exist a function like fun1 ??
    How can we do ?
    Regards

    Hello,
    this is the code that does the job:
    SQL> set serveroutput on
    SQL> DECLARE
    2 ch VARCHAR2(20) :='22+10' ;
    3 i NUMBER ;
    4 BEGIN
    5 EXECUTE IMMEDIATE 'select ' || ch || ' from dual' INTO i;
    6 dbms_output.put_line ('i = ' || TO_CHAR(i));
    7 END ;
    8 /
    i = 32
    Procédure PL/SQL terminée avec succès.
    SQL>
    just you have to do is to create a small stored function that take the string to calculate and return the number result
    Francois

  • Find a value and the position from the string.

    Hi All,
    Actually I have one table called test and it got 2 columns in it one is number and the other one is varchar2. now I need to find a particular value from a string and also the position of first position character of that searched value. For example, I need to search “Small” from the string “This is the small value” and also the position of that letter “S”.
    The result should be ----
    Value Position
    Small 14
    hare krishna
    Alok

    use substr(), instr() like this:
    with
      test as
          select 1 as num, 'This is the small value' as str from dual union all
          select 2 as num, 'This is the very-very small_value' as str from dual
    select num, str,
           substr(substr(str, instr(str, 'small', 1, 1)), 1,
                              nvl(nullif(instr(substr(str, instr(str, 'small', 1, 1)), ' ', 1, 1),0),
                                        length(str)) - 1) as value,
           instr(str, 'small', 1, 1) as position
      from test
    Query finished, retrieving results...
    NUM                  STR                     VALUE      POSITION
      1   This is the small value             small               13
      2   This is the very-very small_value   small_value         23
    2 row(s) retrieved

  • Unable to capture the String[] from a JavaCallOut

    Hi all,
    I am doing an application in which I need to do a java callout which accepts string and return a String array as output. The java class alone is working fine but when I do the Java Callout and pass the string I am getting *"<con:java-content      ref="jcid:-31630335:136f3572827:-3925" xmlns:con="http://www.bea.com/wli/sb/context"/>"* as a response. How should I access array variable in OSB?
    Kindly help me in this.
    Regards
    Phanindra.

    in Java Callouts I would avoid types which are not in THE list of supported types:
    http://docs.oracle.com/cd/E13159_01/osb/docs10gr3/eclipsehelp/ui_ref.html#wp1290279
    java.lang.String[] is supported for INPUT ONLY
    just return some CSV in a String and you will be happy
    or return a XmlObject containing multiple elements
    A con:java-content thingie can be processed only in another Java callout, and not in a OSB message flow....

Maybe you are looking for

  • How can I display a user's real name in release 2?

    In release 1, there was a way to display a welcome message for a user such as "Welcome Jane!" In release 2, I only know how to return the username (using portal.WWCTX_API.get_user) for the user. Is there another procedure available that returns the u

  • VGA picture but no sound

    I have a Toshiba laptop and a flat screen Sceptre TV. I hooked a VGA cable to my computer and laptop and got a good picture, but no sound. The sound still comes through the laptop and not the TV. Is there a setting I need to change?

  • Lag on key press (key event)

    Hello, I am currently working on a simple game in Java. I've used Java's Key_Pressed in Key Event to control a ship moving back and forth with the up and down keys. I've noticed that when a key is pressed there is a short pause before the ship actual

  • APEX post restful service inserts null value

    Oracle APEX 4.2.5 Oracle Rest Data Service 2.0.7 Apache Tomcat 7 Oracle database 11.2.0.4 Oracle APEX PUT web service inserts null value into column. This is either a bug or the documentation does not properly cover how to correctly set PUT restful s

  • Measure tool in Photoshop CS6

    why is the unit of measurement displayed when using the measure tool wrong? I have changed it in the units and rulers in preferences but it is still wrong.