Write 2darray to file

Hey guys,
I have it writing to the file, its just it writes it all on the same line, i want to have a new paragrapgh after the first line an so on;
String outFile[][] ={{"hello", totCircle1},
                      {"hello", totCircle1}};                               
               for (int i =0; i < outFile.length; i++) {
                  for (int j = 0; j < outFile.length; j++) {
               writer.write(outFile[i][j] + " ");
                    writer.flush();
               writer.close();
Can some one please show me how.
Thanks
Mark

Hey i tried that, thanks
for (int i =0; i < outFile.length; i++) {
                for (int j = 0; j < outFile.length; j++) {
               writer.write(outFile[i][j] + " ");
               writer.write(System.getProperty("line.separator"));
it worked but not the way i want;
it displays
eg
word
num
word
num
opposed to what i want
word num
word num
Any other advice guys,
Thanks

Similar Messages

  • How to create and write in a file

    Hello Gurus,
    I am creating a file based on the date and time and writing into that. But, I am still getting exception error and all. Kindly, please let me know.
    thanks for all the help...j
    Error:-
    C:\Usage\JavaFiles>java filename "abc"
    Exception in thread "main" java.io.FileNotFoundException:Detail09-2003-
    03:28:04.doc (The system cannot find the file specified)
    at java.io.FileOutputStream.open(Native Method)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:176)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
    at TowerDetail.main(TowerDetail.java:30)
    Code sample:-
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    import java.sql.*;
    import java.text.*;
    public class TowerDetail{
    public static void main (String[] args) throws IOException{
    String userName = "user";
    String passwd = "pwd";
    String con_db = "jdbc:odbc:datasource";
    String ssn = args[0];
    Vector results = new Vector();
    Connection con = null;
    CallableStatement cstmt = null;
    java.util.TimeZone tz = java.util.TimeZone.getTimeZone("EST");
    java.util.Date now = new java.util.Date();
    DateFormat df = new SimpleDateFormat("MM-dd-yyyy-hh:mm:ss");
    df.setTimeZone(tz);
    String result = df.format(now);
    String fileName = "Detail"+result+".doc";
    File inputFile = new File(fileName);
    FileOutputStream fos = new FileOutputStream(inputFile);
    PrintWriter pw = new PrintWriter(fos);
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    }catch (Exception e) {
    System.out.println("JDBC Error: "+e.getMessage());
    return;
    try{
    con = DriverManager.getConnection(con_db, userName, passwd);
    cstmt = con.prepareCall("{call dbo.sp_usage_detail(?)}");
    cstmt.setString(1, ssn.trim());
    ResultSet rs = cstmt.executeQuery();
    pw.println("Report "+result);
    pw.println("------------------------------------------------------------------------------------
    while(rs.next()){
    .... write in the file...
    pw.println("------------------------------------------------------------------------------------
    pw.close();
    System.out.println("Your file Detail"+result+".doc is ready!!!");
    cstmt.close();
    con.close();
    }catch(SQLException ex){
    System.out.println("SQLException: ");
    System.out.println(ex.getMessage());
    }catch(NullPointerException e){
    System.out.println("Null Pointer Exception: ");
    System.out.println(e.getMessage());

    Now, I got out of the command prompt and reentered. I didn't set any classpath or anything. I have created a subdir \archive in the C:\ and writing an output file [DetailTower.....doc")into that.
    The DetailTower.class is in C:\Detail\ProjectClass dirctory.
    Now at,
    C:\Detail\ProjectClass\java -classpath . DetailTower "abc"
    I am getting this error:-
    C:\Detail\ProjectClass>java -classpath . DetailTower "999999"
    Exception in thread "main" java.io.FileNotFoundException: c:\archive\DetailTower09-10-2003-06:23:40.doc (The system cannot find the file specified)at java.io.FileOutputStream.open(Native Method)
            at java.io.FileOutputStream.<init>(FileOutputStream.java:176)
            at java.io.FileOutputStream.<init>(FileOutputStream.java:131)
            at Detail.main(DetailTower.java:32)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Write to spreadsheet file.vi is storing data in one row only.

    The 8 points of data is going into one column in the spreadsheet. In the "Write to spreadsheet file string.vi" how do I write the 8 points to one row for each cycle?
    I got this VI from NI's web a couple of years ago and forgot how to modify this part. I usume it is within the write file.vi.
    Thank you in advance
    Skip

    I just reread your original post and the way the "Write to Spreadsheet File.vi" that ships with LV works by default is to put 1D arrays into rows. I read your post backwards and told you how to put the data in a column. Sorry.
    In any case, perhaps you need to make sure the Transpose input ISN'T true, and that the delimiter IS a tab.
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • How can I read, millions of records and write as *.csv file

    I have to return some set of columns values(based on current date) from the database (could be million of record also) The dbms_output can accomodate only 20000 records. (I am retrieving thru a procedure using cursor).
    I should write these values to a file with extn .csv (comma separated file) I thought of using a utl_file. But I heard there is some restriction on the number of records even in utl_file.
    If so, what is the restriction. Is there any other way I can achive it? (BLOB or CLOB ??).
    Please help me in solving this problem.
    I have to write to .csv file, the values from the cursor I have concatinated with "," and now its returning the value to the screen (using dbms_output, temporarily) I have to redirect the output to .csv
    and the .csv should be in some physical directory and I have to upload(ftp) the file from the directory to the website.
    Please help me out.

    Jimmy,
    Make sure that utl_file is properly installed, make sure that the utl_file_dir parameter is set in the init.ora file and that the database has been re-started so that it will take effect, make sure that you have sufficient privileges granted directly, not through roles, including privileges to the file and directory that you are trying to write to, add the exception block below to your procedure to narrow down the source of the exception, then test again. If you still get an error, please post a cut and paste of the exact code that you run and any messages that you received.
    exception
        when utl_file.invalid_path then
            raise_application_error(-20001,
           'INVALID_PATH: File location or filename was invalid.');
        when utl_file.invalid_mode then
            raise_application_error(-20002,
          'INVALID_MODE: The open_mode parameter in FOPEN was
           invalid.');
        when utl_file.invalid_filehandle then
            raise_application_error(-20002,
            'INVALID_FILEHANDLE: The file handle was invalid.');
        when utl_file.invalid_operation then
            raise_application_error(-20003,
           'INVALID_OPERATION: The file could not be opened or
            operated on as requested.');
        when utl_file.read_error then
            raise_application_error(-20004,
           'READ_ERROR: An operating system error occurred during
            the read operation.');
        when utl_file.write_error then
            raise_application_error(-20005,
                'WRITE_ERROR: An operating system error occurred
                 during the write operation.');
        when utl_file.internal_error then
            raise_application_error(-20006,
                'INTERNAL_ERROR: An unspecified error in PL/SQL.');

  • Write to measurement file at every n iterations

    Hi guys,
    I would like some help with saving data in labview 2010 SP1 (base development system). I am using a "Write to measurement fil express VI" inside a while loop and the data out from the DAQmn Read is wired to the signal in of the "Write to measurement fil express VI".
    The way I have wired it is the VI saves the data as a text file after it has recorded 100 samples (the nuber of samples to read in this case was set to 100). I would like to know if there is a way to control the rate at which the express VI saves the data. As in, I want the express VI to save the data at specified time interval or at every nth iteration. I have attached the main VI and its 2 sub-VIs for reference. Please let know if anyone can help me resolve this issue. Thank you for your time and inputs in this regard.
    Raj

    Robert,
    First, you must understand that the above code resides inside a loop. The blue square i terminal is known as the iteration terminal. It provides the current loop iteration count, starting from zero.
    The first input (x) to the Quotient & Remainder Function comes from this iteration count (i) terminal of the loop.
    The second input (y) to the Quotient & Remainder Function comes from the control N.
    We wish to write to the measurement file every N iterations of the loop. If we take our current iteration count (i) and divide by our desired N, every Nth iteration of the loop, the remainder will be zero. For all other iterations, the remainder will be non-zero.
    That being said, we check the remainder and compare it to zero. If it is zero, we will send a True value to the Enable terminal on the Write To Measurement File Express VI. Any time a True value is sent, we will write to file. Anytime a False value is sent, nothing will be written to the file.
    The green new_file input on the Write To Measurement File Express VI is used when the "Save to series of files (multiple files)" radio button is selected in the Configure dialog box of this Express VI. When "Save to one file" is selected, this option does not apply, and so it is not included in the input list, which is why you are not seeing this.
    This new_file input is used to tell the Write To Measurement File Express VI when to start writing to a new file.
     

  • WIN7 x64 Home Basic, 0x80070013 when trying to write or delete files. Disk is write protected.

    Hi,
    My SD card reader is not able to write or delete and format sd cards.
    WIN7 x64 Home Basic, 0x80070013 when I trying to write or delete files. When I trying to format I can see a message that disk is write protected. 
    The card is not locked, it's work in Lenovo Idea Pad s10 without any problem, It's also work in my Pentax camera.
    I'm almost sure that the problem is software, but can't find solution.
    Could Any one help me please?
    Laptop is new, 8 days in use. 

    I have network shutdown 2.0.1 installed and the pcns process normally would be abend in 1 or 2 minute's time. What could be the problem ? Consider to upgrade the network shutdown to 2.2.1 version. Could the problem be resolved in new version ? Any precaution needs to be taken when installing the new version ?
    Terence.

  • Need to write/delete a file (token) to/from user's home directory

    I want to build a class that runs on Windows/Unix clients. It needs to get to users' home directories (both environments) and write the token on login, delete it on logout.
    What method (or code snipet) would get a user's home directory?
    What method (or code snipet) would write/delete a file from it?
    Thanks much

    Even if you are not writing an Applet, this is applicable. But I thot if you were, you might need this.
    See 'SignedAppletDemo.java'
    http://developer.java.sun.com/developer/technicalArticles/Security/Signed/

  • How to combine both DAQ AI signal, write and read file in single VI

    Hi
     I am the new user of LabVIEW version 7.1 for testing automation application. I have to measure 33 signals ( mostly analog like temp, pressure, etc...) from NI USB 6210 DAQ system and write in master file for future verfication.From real data or from master file back up have to write  one more file if only the signal reaches steady state , which will used for analysis and same signals to be read from this file parallely & make a waveform and/or table display format.
    Pl. help me to shortout this problem 
    note: I have plan to ugrade labVIEW version 2011 shortly, so let me know doing parrel acquistion write and read file for data analysis in same VI in version 7.1...... 

    Parallel operations in LabVIEW are very simple.  Just code it in parallel and it will work.
    Try taking a look at some of the examples in the NI Example Finder (Help > Find Examples).  There you will find example for writing to and reading from files, as well as data acquistion in parallel with other operations.
    You might need a producer/consumer architecture is you are acquiring data very quickly.
    Chris
    Certified LabVIEW Architect
    Certified TestStand Architect

  • Some Doubts in write into spreadsheet file function

    hi,
    i have some problem with writing the values into excel file...if \ found then the values after will write the values in next rows...
    for eg. if i give 78/58\46/86 then i will write as in picture i hav attached..
    Attachments:
    Mod 1.vi ‏23 KB
    Untitled.png ‏135 KB

    The Write to Spreadsheet File is not the same as writing to Excel -- for that, you should use the Report Generation Toolkit (and there have been a number of posts here, as well as examples that ship with LabVIEW).
    That being said, it is not clear (a) what you are trying to do, and (b) what is (or is not) happening.  The image you attached looks OK ...

  • The Microsoft Access database engine cannot open or write to the file in Report Builder 3.0

    I am trying to build a report in Report Builder 3.0.  I created the Data Source to point to my Excel file and the Data Set.  I drag a couple of fields on to the canvas and then choose Run.  I get the error:  "The Microsoft Access
    database engine cannot open or write to the file.  It is already opened exclusively by another user".  I am using the Excel driver.  Why am I getting this message?  How can I fix this?

    No, now I am getting the error message again.  It is quite long:
    ERROR [HY000] [Microsoft][ODBC Excel Driver] The Microsoft Access database engine cannot open or write to the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view and write its data.
    ERROR [01S00] [Microsoft][ODBC Excel Driver]Invalid connection string attribute Trusted_Connection
    Please help

  • Hi am trying to save Data into a write to measurement file vi using a NI PXI 1042Q with a real time mode but it is not working but when i run it with uploading it into the PXI it save in to the file

    Hi am trying to save Data into a write to measurement file vi using a NI PXI 1042Q and DAQ NI PXI-6229 with a real time mode but it is not working but when i run it without uploading it into the PXI it save in to the file please find attached my vi
    Attachments:
    PWMs.vi ‏130 KB

     other problem is that the channel DAQmx only works at real time mode not on stand alone vi using Labview 8.2 and Real time 8.2

  • How to read the and Write the PDF file give me the solution

    Hi all,
    How to read the and Write the PDF file give me the solution
    My coding is
    import java.io.File;
    import com.asprise.util.pdf.PDFImageWriter;
    import com.asprise.util.pdf.PDFReader;
    import java.io.*;
    import java.io.FileOutputStream;
    public class example {
    // public example() {
         public static void main(String a[])
              try
              PDFReader reader = new PDFReader(new File("C:\\AsprisePDF-DevGuide.pdf"));
                   reader.open(); // open the file.
                   int pages = reader.getNumberOfPages();
                   for(int i=0; i < pages; i++) {
                   String text = reader.extractTextFromPage(i);
                   System.out.println("Page " + i + ": " + text);
    // perform other operations on pages.
    PDFImageWriter writer = new PDFImageWriter(new FileOutputStream("c:\\new11.pdf"));
                   writer.open();
                   writer.addImage("C:\\sam.doc");
                   writer.close();
                   System.out.println("DONE.");
    reader.close();
              catch(Exception e){System.out.println("error:"+e);
              e.printStackTrace();
    I get the pdf content then it returns the string value but ther is no option to write the string to PDF, and we only add a image file to PDF,but i want to know how to wrote the string value to PDF file,
    Please give response immtly
    i am waiting for your reply.
    thanks,
    Suresh.G

    I have some question flow
    How library to use this code.
    I try runing but have not libary.
    Please send me it'library
    Thank you very much!

  • File not found when using write characters to file

    OK, I am missing something really basic here.  Whenever I try to use the Write Characters to File function, if I try to give it a path beyond the C:\filename directory, it returns an error.  In other words, C:\Dan works, but C:\Dan\Test reurns an error. WHAT am I missing?

    Bingo! That is the problem. You have to make sure the directory exists before you attempt to write files to it.
         BTW: In LV there is a function for creating folders programatically. A good way to see if a directory exists is to attempt to list its
                   contents. If the list function returns an error, the directory doesn't exist and you have to create it.
    So make use of the error that the file write returns. If you get an error, start at the root of your path and test to see if each level exists, and if not create it. When you have all the folders in place repeat the file save.
    Mike...
    Message Edited by mikeporter on 05-24-2007 12:55 AM
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • After upgrading to the latest version of itune, I get this message when trying to open itunes: "The I'tunes Library File is locked, on a locked disk, or you do not have permission to write for this file.

    After importing the latest version of itune, I now get this message:  "The I-tunes library file is locked, on a locked disk , or you do not have permission to write for this file.  How do I resolve this?

    check if you have read & write permissions for your music folder. in the finder, right-click on it and get info. unlock the little padlock (you may have to enter your admin password) and change the permission settings if necessary. next, click on the little gear-shaped icon and apply to enclosed items like so
    the important part is to apply to enclosed items !
    also, even if it seems unrelated, try the steps in this support article: iTunes: Missing folder or incorrect permissions may prevent authorization

  • Multiple While Loops Write to One File

    Hello,
    I have three different instruments from which I am sampling, each at a
    different sampling rate.  Each instrument is being sampled in its
    own While loop.  How do I write all the samples I collect to a
    single text file?  I would like something in the following format:
    [Timestamp] [Instrument 1's First Sample] [Instrument 2's First Sample] [Instrument 3's First Sample]
    [Timestamp] [Instrument 1's Second Sample] [Instrument 2's Second Sample] [Instrument 3's Second Sample]
    ...and so on..
    Thank you,
    Olyvia

    ofro wrote:
    I have three different instruments from which I am sampling, each at a different sampling rate.  Each instrument is being sampled in its own While loop.  How do I write all the samples I collect to a single text file?  I would like something in the following format:
    [Timestamp] [Instrument 1's First Sample] [Instrument 2's First Sample] [Instrument 3's First Sample]
    [Timestamp] [Instrument 1's Second Sample] [Instrument 2's Second Sample] [Instrument 3's Second Sample]
    ...and so on..
    This seems like a flawed project.
    If each loop samples at a different rate, the samples will arrive at different times. Typically there won't be a single timestamp for all three samples. Can you explain what you actually want to write to the file from each loop?
    Do you want to write to the file incrementally inside each loop, or do you want to write everything at once after all loops have finished?
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for

  • PL/SQL? Call it P/K!

    What I want to say for PL/SQL is thus: 1) Functions or procedure of PL/SQL with many parameters are bullshit. Parameter count of normal function should be less than eight. 2) Performance of PL/SQL is said a little better than simple SQL statement of

  • Problem with SLQ Date and Daylight Saving Time

    Hi everybody! It seems, that when I have a date in the database, which falls on start of the daylight saving period, it is converted to the previous date. Example: '2001-10-13' will become '2001-10-12' after doing a date = rs.getDate() and then conve

  • P2p cycle query -oracle apps

    Hi... I am using oracle 10g and was trying to link the base tables of p2p cycle and need help on my query: select prla.unit_meas_lookup_code "UNIT", prha.type_lookup_code"PR TYPE", prha.segment1"PR NUMBER", prha.creation_date,null"SUPPLIER", null"INV

  • Dreamweaver cs6 Language Problem.Please Help!

    i intstalled cs6, but the language is German. i can't find English language pack anywhere. if you have english lang. pack please send it to my e-mail(only lang. files). [email protected]

  • Pbcopy and pbpaste exit code 1, no error message

    I have a tough problem. Originally posted here: http://apple.stackexchange.com/questions/115587/pbcopy-exits-code-1-no-error-mes sage I'm trying to use `pbcopy` and `pbpaste` to copy and paste to the clipboard from a shell. I read the man page to lea