Formatted output in output_file

Hello,
String name = "Drabick";
int age = 22;
System.out.print("%s%20d",name,age);Above can be used to write output in nice way, but I want to write output
in separate file.
BufferedWriter out2 = null;
           try {
                  out2 = new BufferedWriter(new FileWriter("Output.txt", true));  
                          // How can I write here so it will be witten in "Output.txt"
                          // in formatted manner :  System.out.print("%s%20d",name,age); ??????????????????????????
                     out2.newLine();                                   
                    out2.close();     
        } catch (Exception e) {
                   System.out.println(e);
           } Thanks.

calypso wrote:
public static void writefile(String[] stringarray){
                 String filename = "myfile.txt";
               int i = 0;
               String n = null;
               try {     
                    FileWriter output = new FileWriter(filename);
                    PrintWriter Competitor = new PrintWriter(output);
                    output.write(" the list is" + "\n");
                         for(i=0; stringarray[i] != null; i++){
                              output.write("\n"+i+") "+stringarray[i]+"\n");
                         } //end for
                    output.close();
                    } catch(IOException e) {
                         System.out.println("Cannot save " + filename);
                         System.out.close();
                         System.exit(0);
                    }//end try
}//end of write fileThis method takes a string array and prints each string onto a new line in a new file called myfile.txt
extract the bits you want, ask if you need any help
calypsothat's great, except anyone could have gone to Google and searched for examples of writing to a file.

Similar Messages

  • Initial-page-number not working in RTF format output

    A report has a parameter for the page number to start with. In rtf template below code is present
    <?initial-page-number:xdoxslt:ifelse(P_FIRST_PAGE_NUM!=’’,number(P_FIRST_PAGE_NUM),1)?>
    The report page number starts with the value which we pass in p_first_page_num in PDF format but in rtf format output it always starts with 1.
    Is initial-page-number not supported in RTF format output ? If not then what is the alternative?

    the method u followed is fine as need a page number staring from a specify value which u input.
    @section is only for resetting page number to 1 for every group and for that pdf and ppt will be fine but only for rtf u need to use that ( pressing F9).
    u can use @section and initial page number combined but they give u same output as get now. rtf output wont support it will only reset 1 every time
    What ever u do rtf output wont support initial page number code ..........
    i mentioned that F9 work around to mention that it is the only work around u have upto now to control rtf output with regards to page number.
    Guru's correct me if i am wrong. wait for a day or two if some one from guru's confirm it .
    If u need real confirmation raise an SR oracle will let u know .

  • 1.4.2 - What is the correct way to format output in the java.io.PrintStream

    With Java 1.4.2:
    What is the correct way to format output in the java.io.PrintStream?
    The following is incorrect, even though it is still used in the The JavaTM Tutorial at: http://java.sun.com/docs/books/tutorial/essential/
    System.out.formatThis returns "cannot resolve the method 'format'"
    Any detailed suggestions or information is greatly appreciated.

    The following is incorrect, even though it is still
    used in the The JavaTM Tutorial at:
    http://java.sun.com/docs/books/tutorial/essential/
    The whole format thing has been introduced in 1.5. The tutorial also states it's been "updated to 1.5.".
    That's all I've got to say for I don't know how you can format a PrintWriter, let alone a PrintStream, prior to 1.5. I'm not really sure there is any way. Any "legacy way", that is. There almost certainly are third-party API which achieve similar results.

  • List format output to excel sheet

    Hi,
        I have a report output in list format. I need to download that into excel sheet. Is it possible to download a list format output to excel sheet or shall I need to convert that into grid format?
    Thanks Barnita.

    HI,
    Use Menu path
    List->Save/Send->File path

  • SQL Developer formatted output

    Hello,
    Could you please help me in getting the formatted output on Oracle sql developer tool, I am not able to find andy options to set
    I have copy paste the result from this tool to excel, I am getting plain text out put, I have more columns and readablity is not there
    Regards,
    Neil
    Edited by: NeilCSE on Apr 6, 2010 6:01 AM

    Hi,
    try this.
    I am on windows
    SQL> spool c:\emp_text.txt;
    Started spooling to c:\emp_text.txt
    SQL> select ename||'|'||empno from emp;
    ENAME||'|'||EMPNO
    JAMES|7900
    FORD|7902
    MILLER|7934
    SMITH|7369
    ALLEN|7499
    WARD|7521
    JONES|7566
    MARTIN|7654
    BLAKE|7698
    CLARK|7782
    SCOTT|7788
    KING|7839
    TURNER|7844
    ADAMS|7876
    14 rows selected
    SQL> spool off;
    Stopped spooling to c:\emp_text.txtThen open in excel as delimeted by |
    Regards,
    Bhushan

  • How to get XML format output from Hyperion Financial Reporting

    Dears,
    We are using Hyperion Financial Reporting to replace FSG in fusion. I found that Hyperion FR report can be exported to html/excel/pdf format. However, I would like the report to export to xml format.It means I only need the xml data source.
    Anyone who knows how to get the xml format output from Hyperion FR, is there any avaiable API?

    I think if you export the report, you will be able to open the .des file in Notepad/Wordpad and see xml content.

  • Properly formatting output to XML

    While the code below would work to format something simple like this:
    <USERS>
    ��<USER>Tim Smith</USER>
    ��<USER>Jack Dempsey</USER>
    ��<USER>John Doe</USER>
    </USERS>
    hd.startDocument();
    AttributesImpl atts = new AttributesImpl();
    // USERS tag.
    hd.startElement("","","USERS",atts);
    for (int i=0;i<id.length;i++)
      atts.clear();
      hd.startElement("","","USER",atts);
      hd.characters(desc.toCharArray(),0,desc[i].length());
    hd.endElement("","","USER");
    hd.endElement("","","USERS");
    hd.endDocument();
    How does one do more complex nesting of xml elements? Such as if I wanted the output to resemble:
    <USERS>
    ��<USER>Tim Smith</USER>
    ��<ADDRESS>14 Main St</ADDRESS>
    ��<CITY>Denver</CITY>
    ��<STATE>CO</STATE>
    </USERS>
    Message was edited by:
    drakester
    Message was edited by:
    drakester

    I don't quit understand your answer. Serializing objects pertains to formatting output?

  • I am not able to open the html format outputs of SQR

    when I am trying to open SQR html formate output generated by SQR jobs not able to open the html format outputs of SQR getting below error
    but I am able to open pdf and excel formats outputs
    "An error was encountered while attempting to retrieve audit_control_info_frm.htm from the Hyperion Reporting and Analysis - System 9. This error is normally encountered when there is no free disk space on the machine hosting Hyperion Reporting and Analysis - System 9 Application. Hyperion Reporting and Analysis - System 9 Application uses a directory on the hard disk to store temporary files while downloading objects. To rectify this problem, if the disk hosting the Hyperion Reporting and Analysis - System 9 Application temporary directory is nearly full, free up additional disk space. After confirming that there is available disk space, restart ALL Hyperion Reporting and Analysis - System 9 servers. <p>Another possible cause of this error is that you have attempted to embed a "Versioned Collection" into your Personal Page. A "Versioned Collection" is typically created when you publish a document and request the creation of an additional compressed copy. Embedded "Versioned Collections" are not supported by Hyperion Reporting and Analysis - System 9.
    A general error was encountered contacting the server.
    Recommended Action: Contact your corporate technical support."

    Welcome to the Apple community.
    Have you tried restarting your web browser, if that doesn't help you might try emptying your web browser's cache.

  • HTML formatted output

    Hi All,
    I have xml source as,
    < SAMPLE_JOB>
    < ORG_DESCRIPTION>>& lt;UL& gt;& lt;LI& gt;& lt;DIV class=MsoNormal style=& quot;MARGIN: 0in 0in 0pt 0.25in& quot;
    & gt;& lt;SPAN style=& quot;FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial; mso-bidi-font-size: 12.0pt& quot;
    & gt;Design and deliver technical training courses to field service engineers, dealer, and customer support
    personnel.& lt;/SPAN& gt;& lt;/DIV& gt;& lt;/LI& gt;& lt;/UL& gt;
    < /ORG_DESCRIPTION>
    < /SAMPLE_JOB>
    when i am previewing in pdf output, i am getting the following for < ORG_DESCRIPTION>
    < UL>< LI>< DIV class=MsoNormal style="MARGIN: 0in 0in 0pt 0.25in">< SPAN style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: Arial;
    mso-bidi-font-size: 12.0pt">Design and deliver technical training courses to field service engineers, dealer, and customer support personnel.< /SPAN>< /DIV>< /
    LI>< /UL>
    I want html formatted output. I saw tims blog. But here in my xml source i am not getting direct tags (instead of "< UL>", i am getting xml output as "& lt; UL & gt;"),
    can i also get the xsl equivalent code for tags like UL, LI, DIV, SPAN..
    Please help me.

    Your XML source is sorta odd.
    Where is it coming from?
    Word?
    This is what your xml should look like:
    < SAMPLE_JOB>
    < ORG_DESCRIPTION>Design and deliver technical training courses to field service engineers, dealer, and customer support
    personnel.< /ORG_DESCRIPTION>
    < /SAMPLE_JOB>
    Then you put it in your rtf and preview in pdf and it would look ok.
    The source xml is the problem - all this stuff is wrong or does not belong:
    & lt;/SPAN& gt;& lt;/DIV& gt;& lt;/LI& gt;& lt;/UL& gt;

  • Formatting output to a file? 1.4.2

    I am writing an application that writes result sets from an oracle 10g database query. This output combines both text and numeric.
    I cannot figure out how to justify the output to the right or left or force the fields to use a set amount of space regardless of the width of the text.
    As a result I get an outfile with perfectly lined up columns except for the one or two where instead of a four digit number there is a single number. This change in width shifts all of the output over.
    My customer goes nuts over this, surely there is a way to format output?

    OK, I tried today, I really did, I just can't get my brain around how to do what I need to accomplish so here is a pseudo example and i am hoping someone can shed some light.
    My application is abstract to enable easy addition of instances of automated reports.
    I have a 2d array that contains the column names for a given query. [0] = column name, [1] = space to be applied after results are added to a string buffer.
    So, something like this:
    StringBuffer entireQueryResults = new StringBuffer();
    String[][] QueryColumns = someObject.getQueryColumnNames();
    ResultSet currResults = someObject.getResultset();
    while(currResults.next()){
    String currRow = "";
    for(int i = 0; i < QueryColumns.length; i++){
       currRow = currRow + currResults.getString(QueryColumns[0])+currResults.getString(QueryColumns[i][1])+"\n";
    entireQueryResults.append(currRow);
    Now, the problem is that there are columns in the queries that have digits, these can range from a single val to 5 and while 98% of them are 3 digits there are random instances where they are a single digit or even a -1. When this happens it throws the output way off and makes it difficult to read in the resulting email report.
    How can I incorporate this into a MessageFormat or ChoiceFormat object to make the output pretty ?

  • Formatting output values

    How can I format output money values to display 2 decimal digits ?
    For examole, for table values 1.20, 2.00 DBMS output displays 1.2 and 2. I want to display all missing zeroes.
    Thanks

    Use a format mask.
    SQL> select to_char(1.2,'999.99') from dual;
    TO_CHAR
    1.20
    SQL> select to_char(2.0,'999.99') from dual;
    TO_CHAR
    2.00

  • Formatted output with JAXB

    Hi, Please help me with the formatting of output XML file using JAXB. This is my client program that marshals xml content into xml file. This program is creating XML file with no indentation at all. I commented out the line
    m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    still getting same xml file with no indentation. Am I doing anything wrong?
    Thanks in advance.
    try {
    // create a Validator
    Validator v = jc.createValidator();
    // validate the content tree
    boolean valid = v.validate( root );
    //logger.info("XML File Validated Successfully" );
         Marshaller m = jc.createMarshaller();
    m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "http://mydomain.com/Schemas/data DT.xsd");
    DataWriter writer = new DataWriter(
    new OutputStreamWriter(new FileOutputStream(fileName),"UTF-8"),
    "UTF-8" );
    m.setProperty("com.sun.xml.bind.namespacePrefixMapper",new NamespacePrefixMapperImpl());
    m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
    m.marshal(root, writer);
    }catch( ValidationException ue ) {
    logger.error( "Caught ValidationException"+ue ); throw new SdarsDBException("Validation Exception "+ue);
    } catch( JAXBException je ) {
    je.printStackTrace();
    } catch( IOException ioe ) {
    ioe.printStackTrace();

    Hi,
    try writing to the FileOutputStream directly.
    I get formatted output this way.
    maybe the DataWriter is doinfg some translatiopn for you?
    Chris

  • Captivate MP4 format output

    Hi,
    I have generated the *.mp4 format output by using captivate 6.0. However, the output quality of the video is not satisfactory. The texts used in the demo are blurred and the image clarity is also not as expected.
    Can someone please help me out in generating a high quality video output.
    Thanks,
    Panendra

    OK.  Well that rules out one of the main reasons people see degradation in output quality,..resizing the content.
    My only other suggestion is that you may need to play around with the publishing settings in Captivate to see if changing something there will improve the quality.

  • COPA line item report, Number format  -output type - object list(ALV).

    Hi,
    I am preparing COPA line item report. I want to change number format (two decimal place). I did the changes in form level then I did the changes in drill down report as well and saved as save definition.
    But changes are not reflecting in- output type - object list(ALV).
    Please provide help in this.
    Regards

    HI
    What t-code you are using to write this line item report ?

  • How to use an .xsl file to transform input XML to re-formatted output XML?

    Hello,
    I have a .xml file from a report that I want to use a stylesheet to transform into a different .xml format.
    I am reading that I can create a .xsl file to read my input and then transform it to a new output .xml file.
    How do I load this into the Apps?
    I tried creating a template definition and loading the .xsl in as type 'XSL-TEXT' and also, I added
    <?xml-stylesheet type="text/xsl" href="Transform.xsl"?> to my xml data source. The output looked the same as the input.
    Has anyone done this before? Any suggestions would be great!
    Thanks
    -CC

    This is how I use e4x with HTTPService:
    import mx.collections.XMLListCollection;
    import mx.rpc.events.ResultEvent;
    [Bindable] private var claimsXLC:XMLListCollection;
    private function claimsHandler(evt:ResultEvent):void{
        claimsXLC = new XMLListCollection(evt.result..claim as XMLList);
    XML data is being returned, but I use XMLList to create the XMLListCollection.
    If this post answers your question or helps, please mark it as such.

Maybe you are looking for

  • Adding NameSpace as Attribute of Element

    Hi all, I have an element called Batch which has the attributes BatchID="" NoOfEntries="" and what I have to do is add another attribute but this attribute needs to be: xmlns="urn:x-commerceone:document:com:commerceone:CBL:CBL.sox$1.0" It doesnt seem

  • How to transfer iWeb site to another Mac in Lion

    Does anyone know how I can move my iWeb site from my Macbook Pro to my iMac.  I've transfered the files, but iWeb doesn't see the data.  I've copied the data to the iWeb folder in my User Library thinking that would help as I've read others have done

  • N95 8GB v20.0.016 - mass memory failure #3

    For the third time my N95 8GB has managed to corrupt its mass memory ("mass memory corrupted") - only this time, I am unable to reformat it at all! The problem behaviour is as follows: Used the phone last night to take several pictures, accessing the

  • Hi, everyone, question about abap query? thank you in advance!

    Hi everyone, there is an information message that "Do all fields used have a name? (use help)" after I click the button "Generate" in tcode(infoset) sq02 with my infoset. can anyone tell me what is wrong? Before I click "generate" my infoset I added

  • Why are my views pages zooming to 300%? What can I do about it?

    I'm putting up new images that open upon clicking my thumbnails. They are zooming to about 300%, even after I change the sizes. they don't do this on any other browser. What can be done about this? It's making my large views look blurry and out of fo