Printing the correct string...

Hi guys,
i've a simple question for you but i'm not able to solve it.
Ihave a string composed by 5 field separated by whitespace
and i want to print it with this format
The first field is a string
The second,the third and the fourth is a double.
How can i do this cast before printing the correct string....?
Please help me with code...

Hi guys,
i've a simple question for you but i'm not able to
solve it.
Ihave a string composed by 5 field separated by
whitespace
and i want to print it with this format
The first field is a string
The second,the third and the fourth is a double.So? If it's already a String, then just print it, and everything will get printed. Of course, if that's not what you want, you'll have to provide more detail.
If you want to split the string up into its pieces, and you know the only whitespace is the separators, then you could do this: String[] pieces = str.split("\\s+"); Read these to learn more about the regex that split uses:
Sun's Regular Expression Tutorial for Java
Regular-Expressions.info

Similar Messages

  • Problem with printing the correct "ical" pages.

    G'day
    I have only recently started using "iCal", on the cloud, having upgraded my laptops to "Lion" and my iPhone to "5", so that I have NOT experienced any of the "syncing" problems of which I have read elsewhere.
    BUT, I do have an irritating problem, the solution to which, being a long-term Mac user, should be obvious.
    The problem stems fronm the fact that I am located on the east coast of Australia, and my laptops know this.
    The first, really daft, thing that I did was to create a whole lot of iCal entries, in iCloud, without noticing that the default timezone was "Pacific".
    So, OK, I fixed that by going into my ID on iCloud and changing the timezone, and then editing every single event that I had entered at that point in time.
    So, I then thought that I had beaten the beast, because I had only been printing "Weekly" calendars, which were OK.
    Today, I decided to print some "daily" calendars, and the system WILL NOT PRINT THE CORRECT DATE.
    My iCal entries are mainly to do with a trip that that starts on 1st August this year. I bring up iCal on the Mac, go to the print page, select 01 Aug 2012, and it prints 31 July 2012.
    This happens whether I tick the "Timezone" preference in iCal on the Mac, or not.
    What else should I do?
    Dave the Desperate

    Hi Srikanth,
    In the second page you can insert a command to set it to goto page 3,and an additional event in the command (only after the end of main window).
    As soon as the main window ends in the second page...u will get the third and rest of the pages.
    Keep the goto next page in PAge 1 as Page2
    and in Page 2 as Page 2.

  • Word Stopped Printing the correct current page, prints page #1 instead

    Word 2013 will no longer print the correct current page when asked to do so--it prints page 1 instead.  There is no problem with the document(s) involved as they will print the correct current page with another user.  If you highlight a selection,
    it will print that correctly, except without the headers and footers.  If you specify the section and page numbers, that also works (and the headers and footers come out OK). The print drivers are not the issue as the printer drivers
    in question are on the print server and work as expected for other users.
    Creating a new profile for the user does fix the problem, but only temporarily, in a week to 2 weeks the problem comes back.  I am looking for a simpler solution than creating a new profile every week or 2 for the user.
    I have tried the following steps without any success.
    Deleted all the normal.dotm files from the computer and have
    Deleted the Word Data key in the HKEY_CURRENT_USER|SOFTWARE\Microsoft\Office\15.0\Word.  

    Hi,
    I first suggest you check the printer setting, since the problem may by caused by the incorrect printer mode. We can also try updating the printer driver to the latest to check the result.
    Is the source file is openning in the Compatibility Mode? Whatever it is, please copy all of content from your current document to a new creating docx to check the result.
    If the issue still persists, please try to repair Office from Control Panel -> Programs -> Programs and Features -> Office 2013 -> Change -> Repair.
    Feel free to let me know if you have any other concern.
    Regards,
    Melon Chen
    TechNet Community Support
    It's recommended to download and install
    Configuration Analyzer Tool (OffCAT), which is developed by Microsoft Support teams. Once the tool is installed, you can run it at any time to scan for hundreds of known issues in Office
    programs.

  • Trouble printing the correct dimensions.

    Hello everyone.Apologies in advance if this a rather basic query. I'm using CS5 on Windows.
    I created a photoshop file using the International Paper settings A4, which is 297 by 210 and 150 pixels per inch.
    I've used the whole area around the document but I left around a 5mm margin around the edge of the document.
    When I come to print the document does not appear to be scaled correctly in the print preview, and then when I come to print on A4 paper measuring exactly 297 x 210 a large part of the image is chopped off at the bottom.
    Can anyone explain to me why Photoshop seems to indicate it is a 297 x 210 file but when it comes to printing it is not scaled correctly?
    LIkewise how I can fix this and avoid it in the future? Many thanks.
    Would be much appreciated.

    Generally speaking, if you make your image so that it fits within the printable space on the printer, and don't use the [ ] Scale To Fit Media option, it should print at exactly the right size.  But it will print your image inside the printable space - right up to the edges of it.
    I think your trouble is that you're trying to anticipate the non-printable space and put it inside your image.
    Figure out what your printable space is, and try making your image just that size.
    -Noel

  • How to print the output string in inverted commas

    hi all,
    my question is
    like i have a string
    "welcome to java"
    using println statement
    i need to print the above statement in inverted commas
    like the output should appear as
    "welcome to java"

    This sounds like part of some homework but what the
    heck ...
    System.out.println("\\"welcome to java\\"");I was trying to anticipate bugs in this stupid forum sofftware, this should be
    System.out.println("\"welcome to java\"");

  • Trouble printing the correct size of PDF doc

    I print large files of legal and letter PDF.  Something changed and now when I queue it all to print, the legal size is not printing the entire doc.  If I queue one page to print at a time, it prints perfectly.

    If this is happening with TextEdit then there is an Apple KB article that states;
    "By default, when you print a document, TextEdit places line breaks at the same places as
    they were on screen. If the lines are too long for the paper you’re printing on, TextEdit
    reduces the size of the font until the lines fit. For example, if the document window is
    very wide, TextEdit must reduce the font size until the lines fit.
    You can have TextEdit keep the font size the same, and change the locations of the line
    breaks instead by selecting "Choose Format" > “Wrap to Page.”

  • HP C309a All in one Printer - Problems with printing documents the correct size.

    Hi I recently purchased an HP 309a as a replacement for an EPSON printer which had to be replaced a couple of times so I thought I would change manufacturer.
    The HP printer prints well in post places but when I print from Excel on an A4 scale it only prints 3/4 size on an A4 page.  I tried everything to get it to print the correct size.  I have adjusted the settings to scale to A4, print boderless etc and it just will not print correctly.
    It seems to be ok in Word and many other programs so I don't know why there is an issue with Excel.  Iam I missing something, please help.
    Also is there any way to default the printer to A4 automatically instead of 8" x 11".

    I also have issues using this printer with Excel/ Word.
    When I am using Excel or Word I have to remove the HP 309a as my default printer.
    when set as default, excel and word just "hang" for up to 3 minutes when opening or saving.
    I called HP who said the printer works with all other files so basically it's tough. One of their tech guys tried to sort it out but couldn't.
    Has anyone else had this same problem? If so, how was it resolved?
    £300 for a printer that doesn't work with MS. It's not funny and I won't buy HP product again.

  • Finding the correct date to print on the report....

    Hi SAP,
    I've hit a road block and I need someone's help please.
    I have a main report that displays employee hrs worked, work dates based on invoice number.
    I also have a subreport that looks at a specific table that prints the entire employee's rate history.  The employee rate history table contains the rate and the effective date, i.e. 01/01/2008 rate: $100, 04/01/2008 rate: $300, etc.  It can contain many rows of information.
    My problem is that I need to figure out what the corresponding rate should be for the given work date on the main report.  The work date can be any date within the given year so I can't link up the work date from the main report and the effective date on the subreport.
    As an example, say, we take the above rates and effective dates as an example.
    On my main report, if I have a work date of 01/05/2008, how can I pull in the $100 rate from the subreport into the main report?  Similarly, if I had a work date of 04/17/2008 how can I pull the $300 as the rate from the subreport into the main report?  I need to figure out what rate is applicable for each work date.
    Any help would be GREATLY appreciated!!
    Z

    Raghavendra,
    Thanks for your reply.  However, the only time the subreport prints data is when the main report's work date's month and year equals the subreport's month's effective date and year's effective date.  However, there can be gaps in the effective dates.  An employee doesn't necessarily get a new rate effective each month.  It could be once a year or 7 times a year. 
    So say you have 2 effective dates for 2008, 01/01/2008 with rate $200, and 05/01/2008 with rate $400.  based on your logic, the only time the subreport will print the correct data for this employee's rate is if the work date is in January of 2008 and May of 2008.  But, if this employee has a work date of 03/01/2008 in the main report, the subreport will print a null value.
    How can I overcome this?
    Thanks,
    Z

  • How make "Scanner" not printing the output in a new line?

    Hi!
    I'm Jordi from Barcelona and I'm new on Java and on this Forum. I have a question to you. I'm developing a testing application that uses the "Scanner".
    Before using it, the app asks a question to the user:
    String strInput;
    Scanner sc = new Scanner(System.in);
    System.out.print("* Please, write your name: ");
    strInput = sc.next();Running this, the app asks me for the options and after pressing "Enter" prints the input string in a new line like this:
    * Please, write your name:
    Jordi
    And I would to get the next:
    * Please, write your name: Jordi
    Does anybody know how to make the "Scanner" print the output in the same line as the question?
    Thanks for your help!
    Jordi

    Running the code,
    import java.util.Scanner;
    public class Test {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            System.out.print("* Please, write your name: ");
            System.out.println("* Hi, "+sc.next());
    }results in the following output:
    * Please, write your name: Bart
    * Hi, BartWhere the first "Bart" is the input I gave.
    If this is not the case, then it has something to do with your IDE or perhaps you didn't recompile and it previously was
    System.out.println("* Please, write your name: "); // println instead of printbut it's all guesses.
    Good luck.

  • Make java run without printing the stack trace

    I have a GUI program which appears to work for all test cases. Basically what it does is prints out data from a linked list allowing the user to traverse the list with Next and Previous buttons which call a list iterator next/previous method call, and then display the current item in the list. The original problem arose when dealing with alternating calls to next and previous, which since list iterator does not have a current pointer, returned the same element ad infinitum. I modified the method to check for alternating button presses, and it seems to work, except for cases where there are two elements in the list. In this case it still works, printing the correct element, but it also prints to the command line an Exception in Thread AWT...NoSuchElementException. My question is, is there any way to tell the program to not print out this stack trace and just keep running quietly through the Exception?

    I'm not an expert at error handling, but wouldn't it work to put the code that throws the exception in a try/catch block?
    like
    try {
        //code that causes exception
    } catch (NoSuchElementException e) {
        //do nothing
    }Might not work, but it's worth a try...

  • I Sorted but I am trying to get the correct Month to print

    {noformat}I am creating a program that requires me to get the highest number and lowest number in a month.I have sorted the Array into a 1 dimesional Array of [12]. Here is my issue How do I get the Highest and lowes number reported while How can I get the correct Month to print? I keep getting Jan and Dec obviously since they are the first and last month.
    I am not sure how to do a sort that will get me the proper month.
    I am creating a program that requires me to chose the highest number and lowest number of the 12 months calculated. I created a seperate sorting array. Currently these number are in the indexed memory location. This Array of numbers is not Initialized! I am just showing what is currently in memory.
    double total [12]={114,93.10,89.30,92.90,98.40,111.00,102.40,105.40,81.40,82.60,80.90,113.40} .
    //intialized
    String[] months={"January","February", "May","June","July","August","September","October","November",
    "December"};
    Here is my issue How do I get the Highest and lowest number printed that also corresponds with the correct month? I have a String of months. I just dont understand how I can do this. My highest numner is 114 which is January and my Lowest 80.89 is November. Is there another part of the swapping I am missing?
    Here is my code. Thank you for your help. I am having issues getting proper code formatting.
    import java.util.Scanner;
    import java.io.*;
    import java.util.*;
    import java.util.Arrays;
    public class MonthRain
        public static void main(String[] args) throws IOException
                    String[] months={"January","February", "March","April","May","June","July","August","September","October","November",
                    "December"};
                    final double [] [] rain = {
                    { 10.1,8.1, 6.8, 4.2, 2.1, 1.8, 0.2, 0.3, 1.1, 2.3, 6.1, 10.4,6.6,5.5, 3.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2,2.3, 6.1, 7.4,6.6, 5.5, 3.8},
                    { 9.2, 9.8, 4.4, 3.3, 2.2, 0.8, 0.4, 0.0, 0.6, 1.7, 4.3, 5.2,6.6,5.5, 3.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2,2.3, 6.1, 7.4,6.6 },
                    { 6.6, 5.5, 3.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2,6.6,5.5, 3.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2,2.3, 6.1, 7.4,6.6, 5.5, 3.8},
                    { 4.3, 4.3, 4.3, 3.0, 2.0, 1.2, 0.2, 0.2, 0.4, 2.4, 3.5, 6.6,6.6,5.5, 3.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2,2.3, 6.1, 7.4,6.6, 5.5, 3.8},
                    { 8.5, 8.2, 1.2, 1.6, 2.4, 0.0, 5.2, 0.9, 0.3, 0.9, 1.4, 7.3,6.6,5.5, 3.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2,2.3, 6.1, 7.4,6.6, 5.5, 3.8},
                    { 10.1,8.1, 6.8, 4.2, 2.1, 1.8, 0.2, 0.3, 1.1, 2.3, 6.1, 7.4,6.6,5.5, 3.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2,2.3, 6.1, 7.4,6.6, 5.5, 3.8},
                    { 9.2, 9.8, 4.4, 3.3, 2.2, 0.8, 0.4, 0.0, 0.6, 1.7, 4.3, 5.2,6.6,5.5, 3.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2,2.3, 6.1, 7.4,6.6, 5.5, 3.8},
                    { 9.2, 9.8, 7.4, 3.3, 2.2, 0.8, 0.4, 0.0, 0.6, 1.7, 4.3, 5.2,6.6,5.5, 3.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2,2.3, 6.1, 7.4,6.6, 5.5, 3.8},
                    { 6.6, 2.5, 3.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.1, 1.3, 2.6, 4.2,3.6,5.5, 3.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2,2.3, 4.1, 7.4,6.6, 5.5, 3.8},
                    { 2.6, 5.5, 3.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.3, 1.3, 2.6, 3.2,6.6,5.5, 1.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2,2.3, 6.1, 7.4,6.6, 5.5, 3.8},
                    { 4.3, 1.3, 4.3, 3.0, 2.0, 1.2, 0.2, 0.2, 0.4, 2.4, 2.5, 3.6,6.6,2.5, 1.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2,2.3, 6.1, 7.4,6.6, 5.5, 3.8},
                    { 8.5, 8.2, 1.2, 1.6, 2.4, 7.0, 5.2, 8.9, 0.3, 0.9, 1.4, 7.3,6.6,5.5, 3.8, 2.8, 1.8, 0.2, 0.0, 0.0, 0.0, 1.3, 2.6, 4.2,2.3, 6.1, 7.4,6.6, 5.5, 3.8}};
                   double [] total=new double [12];
                   double total_rain=0;
                   double average=0;
                   int col=0;
                   int row=0;
                   int i;
                                  for( row=0;row<rain.length;row++){
                                       total_rain=0;
                                       for( col=0;col<rain[row].length;col++){
                                          total_rain+=rain[row][col];
                                               average=total_rain/(col+1);
                                               total[row]=total_rain;
                                       System.out.printf("%9s Total Rain= %4.2f\n ",months[row],total[row]);
                                       System.out.printf("%9s Montly Average= %4.2f\n ",months[row],average);
                                       System.out.printf("\n");
                                               for(i=0;i<total.length;i++){
                                                 System.out.printf("Total Rain=%.2f\n",total);
                                                 double minValue;
                                                                          int sort,index,minIndex;
                                                                          for(sort=0;sort<total.length-1;sort++)
                                                                               minIndex=sort;
                                                                               minValue=total[sort];
                                                                               for(index=sort+1;index<total.length;index++)
                                                                                    if(total[index]<minValue)
                                                                                         minValue=total[index];
                                                                                         minIndex=index;
                                                                          total[minIndex]=total[sort];
                                                                          total[sort]=minValue;
                                                                     System.out.printf("High Rain=%s and Low Month=%s\n",total[sort],total[0]);
                                                                     System.out.printf("\n");
    Edited by: happyfootsie on Dec 6, 2009 1:12 AM
    tried to fix formatting                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    happyfootsie wrote:
    Here is my issue How do I get the Highest and lowes number reported while How can I get the correct Month to print?OK, apart from the fact that you've dumped everything in one place as opposed to breaking up your logic, the main thing I can see is that you have no inherent mapping between the values that you're storing and the months that they apply to.
    That's all fine while you're just pulling in the values (I assume that each block of 12 is listed from January to December), but the second you do a sort, you lose the fact that '114.93', which is probably now in last place (being the highest) actually referred to the month of January.
    First suggestion: break it up into methods (a couple of suggestions would be 'getAverages() and 'sort()', but I'm sure there's more).
    Second suggestion: Have a look at the Java Collections framework (you might want to start here). It has a shed-load of classes for doing exactly what you want.
    Winston

  • ICal under 10.5 doesn't print the List view with To Do's correctly.

    The problem is this: I have a bunch of To Do's in iCal. I usually print them out on paper using the LIST VIEW (print dialog) so that I can take my To Do list with me. Unfortunately, after updating to Leopard 10.5, all the URL's in my To Do's have wierd links to my email and print funny code on paper now. It's like the added feature of To Do's in mail has caused something here. Anyone else experiencing this? By this way, this only happens with old to do's (before the upgrade), not new ones.

    John,
    This has happened to me as well. Our school uses phpicalendar to publish lesson plans to our web server. I have had this happen to three other teachers as well. In order to get them back to the correct server I have to export their calendars to the desktop, create a new calendar and publish it to the correct location, then import their calendars from the desktop. I haven't been able to re-enter the correct URL in the existing calendars - get an error when publishing.

  • Pages are not printing out correctly. I have tried to fix in the options, with no luck. It prints out with spaces in between the letters.

    When I go to print any page from an email, webpage, pdf file..the pages print out very wide fonts to the point where it is unreadable. I have tried to fix in the options with no luck. I can provide you with visuals if you need me to.

    Thanks very much! It works! The print / review print - print works like it is supposed to. The print is corrected and works great. Thanks again.

  • What is the correct format of filepath string on Mac os x?

    I am trying to retrieve a file from Mac os x by:
    File file=new File(filepath);
    My boot volume name is "myVol", and filepath is "/myVol/opt/ab.txt". However, when I provide this path, the file is not found. I just figured out that if I use "/opt/ab.txt" the correct file can be found!!
    Now, if I have a shared volume on my machine(I got it by menu "Go-->Connect to Server..."), whose name is "Mac Share", the filepath should be something "/Mac Share/test/123.txt". File file=new File("/Mac Share/test/123.txt") can not find the file. It looks like that it's trying to find 123.txt from /myVol/Mac Share/test directory, which doesn't exist. I even tried "//MacShare/test/123.txt", "Mac Share/test/123.txt", etc., and none of them worked!!
    If you know the correct format to specify the filepath on Mac OS x, please give me help!!!!
    Thanks in advance.

    I don't know the exact answer to your question, but you can probably figure it out on your own like:
    1) Create a File object that represents an existing file. Play around with the path until the file can be found.
    2) Now that you have a File object representing a valid, existing path, use MyFile.getAbsolutePath() to see what the full path string is. MyFile.getCanonicalPath() might provide some answers as well.
    Whatever getAbsolutePath() returns is the correct format for the file path string.

  • What's the correct way of preparing artwork for print in Illustrator?

    I want to print an illustration on 8.5in. x 11in. paper. Whenever I print, the artwork always fills the whole page and all of the artwork doesn't show. So I created a new document and these are the settings. Are they correct? Thanks in advance.

    Your new document setting are correct, CMYK & 8.5 x 11.
    Unless you have borderless printer you cannot print to the edge of the paper. This keep from toner getting into the printer and one side is usually the shortest so the gripper can grab the paper. Usually this is only about 1/8" around and one side about 1/4".
    If this does not help, can you please provide a measurement of how much is missing and describe where it si your are determining all of the artwork does ton show, is this in the print window or other.

Maybe you are looking for

  • Voice memos iPhone

    I usually don't have problems with the voice memos app, but oneve I've closed the app before my voice memo could be saved properly. Now if I tap "play" it doesn't go on even though the voice wave and all the informations about it are there. Can I do

  • I am trying to sync to Outlook 2010.  I get a weird error message when I am trying to setup on my pc.  Its not english.  It says "der automatische refresh konnte nicht gestartet werden"  Help!

    I am trying to sync to Outlook 2010.  I get a weird error message when I am trying to setup on my pc.  Its not english.  It says "der automatische refresh konnte nicht gestartet werden"  Help!

  • PO and GR

    Dear Friends   im facing a scenario Im making a PR for one equipment.I have made a po and i received GR.Now at the time of issueing they are asking the some parts of the equipment for the installation and after 6 maonts they are asking the remaining

  • Library on more than 1 computer

    i got a new laptop and i want to put my itunes library onto it, but i can't get it off my ipod. it's already in manual mode, i just can't get the songs onto the new library.... dell?    

  • RAW (NEF) files from Nikon D3200

    I previously had a D3000 and was able to open NEF files in Elements 9 with ACR. Now, Having upgrade to a D3200, Elements 9 won't open or even recognise the NEF files. I have contacted Nikon, but they say that the files from the D3200 are 'not compati