Need help cutting down words...

Hi,
I'm creating a method where I have to cut a bunch of characters down to 10 characters.
So Lets say I input ABCDEFGHIJKLM, it shoud return +"ABCDEFGHIJ"+. Also if I have characters shorter than 10 like ABC, it should just return +"ABC "+; with the spaces making up for the characters.
I got the method working, but the problem is that if I enter ABCDEFGHIJKLM, it just cuts it to C and returns +"C "+.
Can someone give me a hint where i'm going wrong with this?
Here's my code:
public static String trimTo10( String s ) {
          String words = "";
          for (int i = 0; i <= s.length() -1; i++) {
               if(words.length()>=0 && words.length()<10) {
                    words = String.valueOf(s.charAt(i));
          if(words.length() < 10) {
               for(int i =words.length() ; i < 10; i++) {
                    words = words.concat(String.valueOf(' '));
          return words;
     }

DarrylBurke wrote:
1. Concatenate a String of 10 blank spaces
2. Extract the first 10 characters.I've done the concatenate part, but I don't understand 2. How do I extract the first 10 characters?
Here's my code
public static String trimTo10( String s ) {
          String n = "     "+"     ";
          for (int i = 0; i <= s.length() -1; i++) {
               if(n.length()>=0 && n.length()<10) {
                    n = String.valueOf(s.charAt(i));
          if(n.length() < 10) {
               for(int i = n.length() ; i < 10; i++) {
                    n = n.concat(String.valueOf(' '));
          return n;
     }

Similar Messages

  • Need to cut a word in half and insert text inside

    need to cut a word in half and insert text inside like this: http://looksgreat.tumblr.com/post/56189410707/tutorial-letra-dividida

    Hi,
    For me, Jongware is right! It's very easy and cool to do it directly in InDesign (with totally editable text). Here's a sample:

  • Need to cut a word in half and insert text inside, in Illustrator or InDesign

    need to cut a word in half and insert text inside, in Illustrator or InDesign, like this: http://looksgreat.tumblr.com/post/56189410707/tutorial-letra-dividida

    That's fine. Everybody has their own preferences. I find it odd that you feel the need to criticize mine. Personally, I've been a Prepress Tech for 25 years, the last 15 in a digital environment on Mac Workstations. I work with live fonts and outlined text every day. I've had way more headaches with font substitution and reflow than I've ever had with vector art. Most of the time, I leave live text as live text. But if I'm designing a Logo or art that is intended to be placed in multiple documents and probably scaled, I'm going to convert it to paths. Much less chance of the RIP screwing it up that way.
    Your answer to OPs question was spot on. So was mine. There is rarely only one right way to create something in Illustrator. If you don't care for my methods, then don't use them. But let me assure you, I don't need any schooling from you. The fact that you seem compelled to engage me on this may say something about your personality. Micro-manage much?

  • Java needs a cut down "media" VM

    What would it take for java to take on flash in the internet media space?
    My thoughts on why flash dominates java:
    The java download is far too big, java is ~7MB, flash is ~1.8MB
    The vm takes far too long to startup
    You get an ugly grey box when the vm is starting up in place of the applet
    What is needed is a cut down java "media" vm. It should:
    Be no larger than the flash download of ~1.8MB
    Have greatly improved startup time. On a modern pc it should be almost instantaneous.
    Be fully upgradable to the "full" vm. For example if the full vm is ~7MB then if you have the media vm installed the full vm download should be ~1.8MB smaller
    As the name implies it should be focused solely on rich media (steaming movies etc)
    It should not cause the java icon to popup on the taskbar by default. It should be transparent to the user that java is running.
    Should not display a grey box in place of the applet when starting up, the box should be black or non-existent.
    The aim would be for sites like youtube to be able to realistically replace flash with java. What do you think?

    >
    Not true, you should probably read a few tutorials. You can already replace that with an image or an animated image.Well I have not written any applets for a long time it is just what I am seeing out there. I have been developing java for over 10 years so I don't need to read any tutorials.
    This is a large development space and java should be taking it over. JVM modularity is the first step in the same direction.

  • Begginer needing help with "package" word

    Hi,
    I'm a Java newbie and I'm trying to get comfortable with programming in Java on my Mac (running Mac OS 10.3).
    I found some sample code that I'm testing out at:
    http://www.macdevcenter.com/pub/a/mac/2001/08/03/osx_java.html?page=1
    but I'm having problems using the reserved word "package".
    at the time of each .java file the sample code has:
    package NineSquares;When I compile this in the Terminal window using the command
    javac NineSquares.java
    javac MainFrame.java
    javac EachSquare.javaI get the following error message:
    NineSquares.java:8: cannot resolve symbol
    symbol : class MainFrame
    location: class NineSquares.NineSquares
    new MainFrame();
    ^
    1 error
    David-Salvays-Computer:~/introcs/Project2 davidsalvay$
    when I comment out the package line it compiles fine.
    I don't understand what package means and how I use it. BTW, all my .java files are in the same folder and I've already set the classpath to the file containing my main method (NineSquares.java).
    Any help/suggestions/ideas will be much appreciated!
    --David                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    1. package is always declared first in a class definition.
    2. If you've got a class foobar, and that class is in package x.y.z, then the .class file needs to be in a file foobar.class under the directory hierarchy x\y\z\foobar.class, and where the directory above x is in the classpath.
    3. The official name of that class is x.y.z.foobar. You can import it using import x.y.z.*; or import x.y.z.foobar; Import just lets you use the class without having to always write x.y.z

  • Need help cutting out images

    Hey
    I realize what Im asking for might be complicated. But any
    help or direction I can get will be appreciated.
    I want to right something that will take a photo realistic
    image, say maybe a 400x300 photo of anything really, and cut out
    peices of the photo, so that I can manipulate these peices after.
    For example...if its a photo of a guy riding a bike and hes wearing
    a blue shirt....I want to cut out the blue shirt part and change
    its color on the fly, just by clicking on the blue shirt.
    Any ideas??
    Oh and does this process have a name?

    Yes, you're right - it is complicated!
    The reason is that with a photo of a guy wearing a blue
    shirt, that blue shirt is actually made up of hundreds of different
    subtle shades of blue.
    So to implement this, you'd need to perform a number steps,
    some of which are fairly complex:
    1) allow the user to select a point in the image
    2) read the colour at that point. You might find you need to
    take an average of a small area around that point to get a better
    approximation of the percieved colour at that point because the
    colour of pixels within a seemingly 'flat' area of colour can
    actually vary significantly. (this is why the photoshop inkdropper
    tool offers 3x3 and 5x5 average options).
    3) gradually 'scan' outwards from the pixel coordinate
    clicked on, checking each adjacent pixel in the image and comparing
    the difference in colour value against the initial colour selected
    (using getPixel). If it is within a certain tolerance, you can
    include it in the selection. You'll need to create an array or
    another image object to store the results in. Repeat this process
    until there are no more adjacent pixels that fall within the colour
    tolerance range.
    4) Use an RGB->HSB routine to convert the colour values to
    HSB, so that you can then adjust the 'Hue' value, and finally
    convert back to RGB. I have one here:
    http://robotduck.com/content/articles/director/imageManipulation/shiftHue.txt
    And whether it has a name?..
    well, the tool which selects an area within a certain colour
    range in photoshop is called the 'magic wand', so I guess that's a
    good way to refer to it - a magic wand function. And to change the
    colour by 'rotating' the colour values through the colour spectrum
    (which is what my example code does) is called 'shifting the hue'
    of the colours.
    hope this helps!
    - Ben

  • Need help cutting out a middle section of a song!

    I have a song that I want to cut out a large portion of the middle.
    I have no Garageband experience, so googled/youtubed info.
    I THINK I have properly split in the two places where the cut needs to be made, but when I delete that portion between the 2 splits, I cannot get it to join properly! It's like only a small bit has been deleted, NOT what I split and deleted!
    Please help!!! I need this done by today!
    Thanks so much!

    I THINK I have properly split in the two places where the cut needs to be made, but when I delete that portion between the 2 splits, I cannot get it to join properly!
    That should work. Have you "Snap to Grid" enabled? Then turn the grid off; you toogle it on and off in the "control" menu in the main menu bar (Choose Control > “Snap to Grid ⌘G).

  • Need help cutting out an uneven section

    I have a picture that I have drawn and scanned into Photoshop Elements 6. What I need to do is cut around the image so it is just the actual picture no background. The image is an uneven oval.

    You can use any of the selection tools to isolate the part of the image you want and then save as a new document.
    If there is a difference between the drawing and the background that you scanned on you could try using the magic wand to select the background (then invert the selection to get the drawing) or use the magnetic or polygonal lasso to select the drawing. Once you have your selection, copy it (ctrl-C) then go to File>New and paste what you copied into the new document.
    For the uneven oval shape you will want to save the new document in a format that supports transparency (GIF, for example). Without transparency, your image will always look like a rectangle, even if only the oval is 'there'.
    Bob Warren

  • Connection issue - Need help narrowing down

    Hi guys. Trying to pinpoint what's wrong with my connection. I've got a Westell 7500 on DSL. The speed is great, except every so often I'll lose my connection. Happens once every couple of weeks or so and it's usually at night around 8:00. All the lights on the modem/router look normal. But neither one of my 2 computers in the room can get a connection. I can't even log in to the router when this happens. After about an hour the connection appears to fix itself and switch back on. I've tried switching the router off and on to re-establish the connection but it seems to have no effect. Only thing I noticed is when I power-cycle it, the LED on the router labeled "Internet" sometimes remains off. Other times it stays solid green, even though the connection still doesn't work.
    When it's back online and I check my transceiver stats they look fine. I can post 'em if you guys want but everything looked within normal range to me and I have no speed problems so I don't think line quality is the issue.
    Even if you can't help me solve the problem, I hope someone can at least help me figure out whether it's a faulty router or Verizon's service in the area just shuts down temporarily (service status page never says anything).
    Thanks in advance!

    Had another disconnection. But I was able to get to the router and re-connect right away. Usually doesn't even let me get to the router. Anyways, do these entries from the log mean anything to you guys? I lost the connection at about 22:59.
    Oct 26 23:00:32      daemon.err      cwmpd[3578]:      ddnsWanIPCallback WAN State Down
    Oct 26 23:00:30     daemon.notice     net_mgr[355]:     Routes transitioning to Down state on ppp0.
    Oct 26 23:00:30     daemon.notice     net_mgr[355]:     QoS on ppp0 transitioning to Down state.
    Oct 26 23:00:29     daemon.notice     pppd[3313]:     Westell PPP Environment:device:nas1 linkname:config0 iplocal:173.52.143.220 ipremote:10.32.173.1 ppplogname:root orig_uid:0 connect_time:309909413 bytes_sent:358019859 bytes_rcvd:3455869189 usepeerdns:1 dns1:68.237.161.12 dns2:71.243.0.12
    Oct 26 23:00:29     daemon.notice     pppd[3313]:     Westell phase_hook PHASE=PHASE_HOLDOFF(11)
    Oct 26 23:00:29     daemon.notice     pppd[3313]:     Westell Random Holdoff returning 497 seconds
    Oct 26 23:00:29     daemon.warn     pppd[3313]:     Leaving destroy_pppoesessionfile
    Oct 26 23:00:29     daemon.err     pppd[3313]:     Unlinking PPPoE session file:/WFIO/ppp-config0
    Oct 26 23:00:29     daemon.warn     pppd[3313]:     Enter destroy_pppoesessionfile
    Oct 26 23:00:29     daemon.notice     pppd[3313]:     Westell PPP Environment:device:nas1 linkname:config0 iplocal:173.52.143.220 ipremote:10.32.173.1 ppplogname:root orig_uid:0 connect_time:309909413 bytes_sent:358019859 bytes_rcvd:3455869189 usepeerdns:1 dns1:68.237.161.12 dns2:71.243.0.12
    Oct 26 23:00:29     daemon.notice     pppd[3313]:     Westell phase_hook PHASE=PHASE_DISCONNECT(10)
    Oct 26 23:00:29     daemon.info     pppd[3313]:     Sent 358019859 bytes,received 3455869189 bytes.
    Oct 26 23:00:29     daemon.info     pppd[3313]:     Connect time 5165156.9 minutes.
    Oct 26 23:00:29     daemon.notice     pppd[3313]:     Connection terminated.
    Oct 26 23:00:29     daemon.notice     pppd[3313]:     Westell PPP Environment:device:nas1 ifnamepp0 linkname:config0 iplocal:173.52.143.220 ipremote:10.32.173.1 ppplogname:root orig_uid:0 connect_time:309909413 bytes_sent:358019859 bytes_rcvd:3455869189 usepeerdns:1 dns1:68.237.161.12 dns2:71.243.0.12
    Oct 26 23:00:29     daemon.warn     pppd[3313]:     pppd[3313] EXIT_PEER_DEAD caused InternetFail light to be lit
    Oct 26 23:00:29     daemon.notice     pppd[3313]:     PPPD Exit Status changed EXIT_OK->EXIT_PEER_DEAD during phase PHASE_ESTABLISH->PHASE_DEAD
    Oct 26 23:00:29     daemon.notice     pppd[3313]:     Westell phase_hook PHASE=PHASE_DEAD(0)
    Oct 26 23:00:23     daemon.notice     ip-down[3617]:     ppp0: 358019859 bytes sent,3455869189 bytes received
    Oct 26 23:00:23     daemon.notice     ip-down[3617]:     ppp0: disconnected;connected for 309909413 seconds
    Oct 26 23:00:23     daemon.warn     pppd[3313]:     Couldn t increase MRU to 1500
    Oct 26 23:00:23     daemon.warn     pppd[3313]:     Couldn t increase MTU to 1500
    Oct 26 23:00:23     daemon.notice     pppd[3313]:     Westell PPP Environment:device:nas1 ifnamepp0 linkname:config0 iplocal:173.52.143.220 ipremote:10.32.173.1 ppplogname:root orig_uid:0 connect_time:309909413 bytes_sent:358019859 bytes_rcvd:3455869189 usepeerdns:1 dns1:68.237.161.12 dns2:71.243.0.12
    Oct 26 23:00:23     daemon.notice     pppd[3313]:     Westell phase_hook PHASE=PHASE_ESTABLISH(4)
    Oct 26 23:00:23     daemon.notice     pppd[3313]:     Westell PPP Environment:device:nas1 ifnamepp0 linkname:config0 iplocal:173.52.143.220 ipremote:10.32.173.1 ppplogname:root orig_uid:0 connect_time:309909413 bytes_sent:358019859 bytes_rcvd:3455869189 usepeerdns:1 dns1:68.237.161.12 dns2:71.243.0.12
    Oct 26 23:00:23     daemon.notice     pppd[3313]:     Westell phase_hook PHASE=PHASE_NETWORK(7)
    Oct 26 23:00:23     daemon.notice     pppd[3313]:     Westell PPP Environment:device:nas1 ifnamepp0 linkname:config0 iplocal:173.52.143.220 ipremote:10.32.173.1 ppplogname:root orig_uid:0 connect_time:309909413 bytes_sent:358019859 bytes_rcvd:3455869189 usepeerdns:1 dns1:68.237.161.12 dns2:71.243.0.12
    Oct 26 23:00:23     daemon.notice     pppd[3313]:     Westell ip_down()
    Oct 26 23:00:23     daemon.notice     pppd[3313]:     Westell PPP Environment:device:nas1 ifnamepp0 linkname:config0 iplocal:173.52.143.220 ipremote:10.32.173.1 ppplogname:root orig_uid:0 usepeerdns:1 dns1:68.237.161.12 dns2:71.243.0.12
    Oct 26 23:00:23     daemon.notice     pppd[3313]:     Westell phase_hook PHASE=PHASE_TERMINATE(9)
    Oct 26 23:00:23     daemon.notice     pppd[3313]:     Serial link appears to be disconnected.
    Oct 26 23:00:23     daemon.info     pppd[3313]:     No response to 6 echo-requests
    Oct 26 22:51:30     daemon.info     dnsmasq[325]:     DHCPACK(br0) 192.168.1.21 00:90:4b:e7:f0:11 mussel
    Oct 26 22:51:30     daemon.info     dnsmasq[325]:     DHCPREQUEST(br0) 192.168.1.21 00:90:4b:e7:f0:11 

  • Need help importing large word document into CS2

    I am using ID CS2. I am putting together a document that has 120 pages that's 11.625 wide by 21.25 tall (newspaper) and will be in 8 columns. I want to place a text document using the autoflow method. My problem is, there are so many words, characters, etc. that my ID freezes up. I have changed the original document to a Word Doc, Excel file and a text document. Changing the type document seemed to make a difference. What is the best way to place the text and format it?

    Technically, you don't need to draw the text box first. If you already have your margins and columns correct (which I assume you have set up on the master so it automatically applies to all pages), ID will create the textbox when you autoflow (shift click or alt click with a loaded curser). Just click with your loaded curser in the top left of the first column.  Another way to do this is to create an 8 column text box on your master and click over it on the actual page.  The advantage to this is that you don't have 8 text boxes across your page, but one single text box divided into eight columns.  There are pros and cons to both work flows, though it appears that the new CS5 has more pros to the single text box with columns than the eight text boxes.
    You should only remove the styles and formatting if you want all the formatting stripped from the file as you place it. Otherwise, you can actually map the styles in the placed document to the ones in the ID file from that dialog box, and that might save you a lot of formatting time with such a large document--assuming that the file you are placing is correctly styled and formatted (which is not always the case).
    Since I'm now not sure what you meant by ID "freezing" in your original post--if ID actually crashes (closes itself with or without an error message) when you try this import, you might try opening the final text doc and breaking it up into smaller segments to place. However, there should be no problem placing a text document of that length into ID. If ID is just pausing for a while, do give it time to actually process all those pages.

  • Need help with Microsoft Word 2008 for Mac

    When I paste a picture in a word document and save it, it seems to show up without a problem. But when I go back in to edit or print the document, the picture is no longer there, only a box with a big red X in it (I've inserted a sample of what shows up). Does anyone know how to fix this problem? Thanks!

    Thanks for the suggestions, AussieDJ, but unfortunately I don't have a clue under what format to save a document other than as a word document. If anyone out there has encountered this problem with Word 08 and has some suggestions to resolve the issue, I'd sure appreciate hearing from you! Thanks!

  • Problems with G5-Need Help Narrowing Down Issue

    I have I PowerMac G5 dual 2.0 GHz from the June 2004 bracket and am having issues getting it to turn on. When I press the power button I will get one of three results. One: the light will come on when pressed, the fans will rev and I can hear the hear drive start to work, but the power light will go back out after a second or two while the fans still spin. Second: the power button is depressed and no light comes on but the fans, hard drive start up, etc. Third but least common is that the power button is depressed and it will come on as normal, boot up just fine and I'm able to use the computer-going as far as running apps and games with no problem. I've taken the steps mentioned in other threads such as resetting the PSU, swapping batteries, reseating video card/RAM but the results with start up are varied so much as to I can't tell what (if anything) is helping. I don't know if it's power supply issue (because the fans and other things seem to work fine) or a motherboard issue (but that wouldn't explain why it works fine when it wants to). I'm stuck. Any help is greatl appreciated.

    Hi fiveinchwrench-
    Usually this problem is either a power supply or mother board. It sounds more like a power supply to me but there is no way to tell from here.
    It may be worth taking it to an Authorized Apple Repair Center for a diagnosis. Both a power supply and a mother board will probably be in short supply, but the power supply will by far be the cheaper component.
    Luck-
    -DaddyPaycheck

  • Need help cutting out unwanted song

    I have about a 4 and a half minute movie clip I made, but it has turned into over 7 minutes long because of a song which continues past the end of the video. How do I cut out that last 3 minutes of the song to have my movie stop exactly when the video does?

    you edit audio same as video:
    switch to timeline view..
    select audio track...
    set playhead to 'edit' point..
    hit Apple-T (that splits the audio track...)
    select unwanted part
    hit delete
    done.

  • Need help reactivating Microsoft Word

     I have the code, but it's not compatible with account. I have paid for it, but it won't link up to my account.

    Its actually pretty easy to understand why anyone might post multiple threads on occasion at present ,Templeton, while the software changeover for the discussions is still having teething problems . I did the same myself yesterday when the servers were refusing to acknowldge receipt of anything new that was sent their way.
    The same problems can also make spelling hard to correct. If the server doesn't even show your post for a couple of hours you will inevitably miss the chance of editing.
    Much better to focus on the real question facing the poster, rather than trivial issues, don't you think, especially while the changeover is still really under way?
    Cheers
    Rod

  • Help urgently needed, I have installed Logic Pro 9, since then my Final Cut Pro X keep freezing. Anyone what is wrong and how to solve it? I desperately need help on this. Thanks

    Help urgently needed, I have installed Logic Pro 9, since then my Final Cut Pro X keep freezing. Anyone what is wrong and how to solve it? I desperately need help on this. Apple support says I have to pay £85 for to help me. Thanks

    Just a word of advice. Never ever use the word "urgent" on this forum

Maybe you are looking for