Writing ASCII 0x81 to file with PrintStream

Hello
I am trying to export textfiles to an other system (IBM AS400). But for that i need to convert some special characters. It works fine with most of the characters (i simply replace the characters in the String that i write to the File (String.replace(oldchar, newchar))
One character gives me trouble. I need to convert the char 0xFC to 0x81. But if i try to write this character to the File (I am using PrintWriter because i want to use the println(...) method) all i get in the File is the character 0x3F.
I tried different methods to write this char (0x81) but only if i use the OutputStream directly am I able to write 0x81 to the File.
Here is a sample code to illustrate my problem
public static void main(String[] args) {
        FileOutputStream fo = null;
        PrintStream p = null;
        //PrintWriter p = null; //if i use PrintWriter the problem is the same
        FileReader fi = null;
        BufferedReader d = null;
        String sampleFile = "c:\\only81.txt"; //contains 3 Lines of (char)0x81
        String outFile = "c:\\test.txt";
        try {
            fo = new FileOutputStream(outFile);
            p = new PrintStream(fo);
            fi = new FileReader(sampleFile);
            d = new BufferedReader(fi);
            p.println("Test to write ASCII 0x81 (129)");
            String temp = null;
            while ((temp = d.readLine()) != null)
                p.println(temp);  //all stored chars are 0x3F
            for (char i = 1; i<512; i++) //char 0x80-0x9F are all
                p.print(i);                     //stored as 0x3F (also chars>FF)
            p.flush();
            fo.write(129);     //these 4 lines actually work
            fo.write(0x81);
            fo.write((char)129);
            fo.write((char)0x81);
            d.close();
            fi.close();
            p.close();
            fo.close();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
    }What i would really like to understand is why there is the problem with the chars 0x80-0x9F (even my IDE (Eclipse)) has problems displaying the char in its Editor)
and how i can write 0x81 to a file (when 0x81 is part of a String)

You are writing with the default encoding, which is UTF-8Printwriter p = new PrintWriter(new OutputStreamWriter(new FileOutputStream(outFile), "ISO-8859-1"));will not have the same problem.
Use the same for readingBufferedReader d = new BufferedReader(new InputStreamReader(new FileInputStream(sampleFile), "ISO-8859-1"));

Similar Messages

  • Can someone help with a previous post labeled "Writing to a data file with time stamp - Help! "

    Can someone possibly help with a previous post labeled "Writing to a data file with time stamp - Help! "
    Thanks

    whats the problem?
    Aquaphire
    ---USING LABVIEW 6.1---

  • High Score Table: Writing a Simple Text File with Flash and PHP

    I am having a problem getting Flash to work with PHP as I need Flash to read and write to a text file on a server to store simple name/score data for a games hi score table. I can read from the text file into Flash easily enough but also need to write to the file when a new high score is reached, so I need to use PHP to do that. I can send the data from flash to the php file via POST but so far it is not working. The PHP file is confirmed as working as I added an echo to the file which displayed a message so I  could check that the server was running PHP - the files were also uploaded to a remote server so I  could test them properly. Flash code is as follows:
    //php filewriter
    var myLV = new LoadVars();
    function sendData() {
    //sets up variable 'hsdata' to send to php
    myLV.hsdata = myText;
    myLV.send("hiscores.php");
    I believe this sends the variable 'myText' to the php file as a variable called 'hsdata' which I want the php file to write into a text file. The mytext variable is just a long string that has all the scores and names in the hiscore. OK, XML would be better way of doing this but for speed I just want to get basic functionality working, so storing a simple text sting is adequate for now. The PHP code that reads the Flash 'hsdata' variable and writes it to the text file 'scores.txt' follows:
    <?php
    //assigns to variable the data POSTed from flash
    $flashdata = $_POST["hsdata"];
    //file handler opens file and erases all contents with w arg
    $fh = fopen("scores.txt","w");
    //adds data to file
    fwrite ($fh,$flashdata);
    //closes file
    fclose ($fh);
    echo 'php file is working';
    ?>
    Any help with this would be greatly appreciated - once I can get php to write simple text files I should be ok. Thanks.

    Thanks for your help.
    I have got Flash working to a certain extent with PHP using loadVars but have been unable to get flash to receive a variable declared in PHP. Here's my Flash code:
    var outLV = new LoadVars();
    var inLV = new LoadVars();
    function sendData() {
    outLV.hsdata = "Hello from Flash";
    outLV.sendAndLoad("http://www.mysite.com/hiscores/test23.php",inLV,"post");
    inLV.onLoad = function(success) {
    if (success) {
      //sets dynamic text box to show variable sent from php
      statusTxt.text = phpmess;
    } else {
      statusTxt.text = "No Data Received";
    This works ok and the inLV.onLoad function reports that it is receiving data but does not display the variable received from PHP. The PHP file is like this:
    <?php
    $mytxt =$_POST['hsdata'];
    $myfile = "test23.txt";
    $fh = fopen($myfile,'w');
    //adds data to file
    fwrite($fh, $mytxt);
    //closes file
    fclose ($fh);
    $mess = "hello there from php";
    echo ("&phpmess=$mess&");
    ?>
    The PHP file is correctly receiving the hsdata from flash and writing it to a text file, but there seems to be a problem with the final part of the code which is intended to send a variable called 'phpmess' back to Flash, this is the string "hello there from php". How do I set up Flash and PHP so that PHP can send a variable back to Flash using echo? Really have tried everything but am totally baffled. Online tutorials have given numerous different syntax configurations for how the PHP file should be written which has really confused me - any help would be greatly appreciated.

  • Writing text to a file with a socket

    i'm writing an applet which is suppose to write the user's input to a txt file on the server's machine.
    i'm reading the information from this txt file by BufferedReader and have found out that it is not possible to use BufferedWriter to write in a similar fashion.
    in postings i have seen that i need to use one of 3 methods. 1) sign my applet, 2) servlets 3) sockets.
    i have choosen to use sockets, but i cannot figure out how to print the information i want to send, to the particular file.
    heres the code i have.... pretty much taken straight off of this tutorial
    http://java.sun.com/docs/books/tutorial/networking/sockets/readingWriting.html
    Socket echoSocket = null;
    PrintWriter out = null;
    try {
    echoSocket = new Socket(server, 8080);
    out = new PrintWriter(echoSocket.getOutputStream(), true);
    } catch (UnknownHostException e) {
    e.printStackTrace();
    System.exit(1);
    } catch (IOException e) {
    e.printStackTrace();
    System.exit(1);
    out.println("line");
    out.flush();
    out.close();
    echoSocket.close();
    i also don't think that i have the proper name of the server defined. i know that the socket connects to the server, but i don't believe it is connecting in the right position.
    i.e. if the server name is "fred" and where the variable server is, i put "fred"....it connects. but, i don't have my files stored directly on fred, they are in subdirectories of "fred" and i can't figure out how i will go about changing the variable server, in order to reach these subdirectories.
    i hope this isn't too confusing
    thanks
    Andy

    do sockets need to have a server program running on the server?

  • Problems writing from BLOB to File with Thin-drivers

    I'm having problems when I'm trying to put a blob to a file
    using jdbc-thin drivers(8.1.5).
    It works perfectly well with the oci-drivers but not with thin.
    When I execute the same code with the thin-drivers I get:
    Error: java.io.IOException: ORA-21560: argument 2 is null,
    invalid, or out of range
    ORA-06512: at "SYS.DBMS_LOB", line 640
    ORA-06512: at line 1
    Please help me...
    /Stefan Fgersten
    lob_loc = ((OracleResultSet)rset).getBLOB(1);
    in = lob_loc.getBinaryStream();
    FileOutputStream file =
    new FileOutputStream("d:/dir/picture.jpg");
    int c;
    while ((c = in.read()) != -1)
    file.write(c);
    file.close();
    in.close();
    null

    Has anyone managed to find a solution (other than switching drivers) for this? I too am using the 8.1.5 thin driver on an 8.1.5 database and receive the same error. Please help!!
    Nkem
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Stefan Fgersten ([email protected]):
    I'm having problems when I'm trying to put a blob to a file
    using jdbc-thin drivers(8.1.5).
    It works perfectly well with the oci-drivers but not with thin.
    When I execute the same code with the thin-drivers I get:
    Error: java.io.IOException: ORA-21560: argument 2 is null,
    invalid, or out of range
    ORA-06512: at "SYS.DBMS_LOB", line 640
    ORA-06512: at line 1
    Please help me...
    /Stefan Fgersten
    lob_loc = ((OracleResultSet)rset).getBLOB(1);
    in = lob_loc.getBinaryStream();
    FileOutputStream file =
    new FileOutputStream("d:/dir/picture.jpg");
    int c;
    while ((c = in.read()) != -1)
    file.write(c);
    file.close();
    in.close();<HR></BLOCKQUOTE>
    null

  • Writing to a data file with time stamp - Help!

    My program currently asks the user to enter a path to save the data from my virtual channels. What I want is to have a default directory to store my data in and also have the file name that is created to be the date. I tried to use create open or replace but I cant get it to work. Any suggestions would be great. Also and comments to the code would help out a lot.
    Thanks
    Attachments:
    Test.vi ‏141 KB

    Look at the attachment. It uses a front panel path control set to only select a new or existing folder (right click and Browse Options). Then, using a Build Path and a Format Date/Time String, a full path to a file is created. Pass this to your Open/Create/Replace File.
    Attachments:
    Date to File Name.vi ‏13 KB

  • Writing a Compressed AVI File in NI LabWindows/CVI with the IMAQ Vision Acquisition

    I'm still facing some problems when I try to save pictures from a GigE Vision camera into a compressed avi-file in a LabWindows/CVI application on Windows7.
    The task is to grab images from the camera with 30 fps to monitor a process, evaluate the grabbed pictures to find certain characteristics of the monitored process and save them in an avi-file to have the possibility to load and evaluate them once again Offline if necessary.
    My questions: which compression filters can I get with the NI-Imaq Vision Acquisition and Vision Development Runtime 2012 SP1? Is a mpeg4 codec available to compress quickly and effective? Can I use a third party codec or only the ones delivered with NI-Vision?
    I posted the problem two times already, but there is little response up to now. Thanks

    The encoding algorithm, or codec, that's used for compression needs to present on your system. When I had done some research on this sometime back, I found that if your custom codec could align with the DirectShow architecture, then your codec would work with IMAQ AVI functions.The codecs that are available may vary from system to system, depending on what software is currently installed. Be sure to check out this article:
    Writing a Compressed AVI File with the IMAQ Vision Acquisition Software
    Adnan Zafar
    Certified LabVIEW Architect
    Coleman Technologies

  • Why do I get a NI-488 error massage when writing into a file and at the same time copiyng this file with a backup softwarre like Easy2Sync?

    I have a small LabVIEW program which writes random numbers very fast into a ASCII-file. I want that file to be copied to a new position every 10 min. Therefor I use a backup/synchronisation software which is doing a copy operation every 10 min. It works fine a certian amount of time and after a while I get either an LabVIEW error (LabVIEW: Fiel already open: NI-488 Comand requieres GPIB Controller to be System controller) or an backup-software error (couldn´t open file...whatever). I´m guessing, it has something to do with file-access but I don´t know why?!? If I run the LabVIEW program and I copy and paste the random-number-file with the windows explorer very fast (pressing ctrl+v rapidly) while LabVIEW is still writing into this file, no error appears. Can sombody help me?
    LabVIEW 2011

    Hi Serdj,
    you don't get a GPIB error, the error number has just 2 different explanations...
    Well, you have two programs accessing the same file. One program just wants to make a copy, the other (LabView) is trying to write to the file. When copying a file that is written to you get inconsistent results! That's why one of both programs is complaining an error...
    You can't have write and read access at the same time! (But you can have more than one read access at the same time...)
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Writing a java program for generating .pdf file with the data of MS-Excel .

    Hi all,
    My object is write a java program so tht...it'll generate the .pdf file after retriving the data from MS-Excel file.
    I used POI HSSF to read the data from MS-Excel and used iText to generate .pdf file:
    My Program is:
    * Created on Apr 13, 2005
    * TODO To change the template for this generated file go to
    * Window - Preferences - Java - Code Style - Code Templates
    package forums;
    import java.io.*;
    import java.awt.Color;
    import com.lowagie.text.*;
    import com.lowagie.text.pdf.*;
    import com.lowagie.text.Font.*;
    import com.lowagie.text.pdf.MultiColumnText;
    import com.lowagie.text.Phrase.*;
    import net.sf.hibernate.mapping.Array;
    import org.apache.poi.hssf.*;
    import org.apache.poi.poifs.filesystem.*;
    import org.apache.poi.hssf.usermodel.*;
    import com.lowagie.text.Phrase.*;
    import java.util.Iterator;
    * Generates a simple 'Hello World' PDF file.
    * @author blowagie
    public class pdfgenerator {
         * Generates a PDF file with the text 'Hello World'
         * @param args no arguments needed here
         public static void main(String[] args) {
              System.out.println("Hello World");
              Rectangle pageSize = new Rectangle(916, 1592);
                        pageSize.setBackgroundColor(new java.awt.Color(0xFF, 0xFF, 0xDE));
              // step 1: creation of a document-object
              //Document document = new Document(pageSize);
              Document document = new Document(pageSize, 132, 164, 108, 108);
              try {
                   // step 2:
                   // we create a writer that listens to the document
                   // and directs a PDF-stream to a file
                   PdfWriter writer =PdfWriter.getInstance(document,new FileOutputStream("c:\\weeklystatus.pdf"));
                   writer.setEncryption(PdfWriter.STRENGTH128BITS, "Hello", "World", PdfWriter.AllowCopy | PdfWriter.AllowPrinting);
    //               step 3: we open the document
                             document.open();
                   Paragraph paragraph = new Paragraph("",new Font(Font.TIMES_ROMAN, 13, Font.BOLDITALIC, new Color(0, 0, 255)));
                   POIFSFileSystem pofilesystem=new POIFSFileSystem(new FileInputStream("D:\\ESM\\plans\\weekly report(31-01..04-02).xls"));
                   HSSFWorkbook hbook=new HSSFWorkbook(pofilesystem);
                   HSSFSheet hsheet=hbook.getSheetAt(0);//.createSheet();
                   Iterator rows = hsheet.rowIterator();
                                  while( rows.hasNext() ) {
                                       Phrase phrase=new Phrase();
                                       HSSFRow row = (HSSFRow) rows.next();
                                       //System.out.println( "Row #" + row.getRowNum());
                                       // Iterate over each cell in the row and print out the cell's content
                                       Iterator cells = row.cellIterator();
                                       while( cells.hasNext() ) {
                                            HSSFCell cell = (HSSFCell) cells.next();
                                            //System.out.println( "Cell #" + cell.getCellNum() );
                                            switch ( cell.getCellType() ) {
                                                 case HSSFCell.CELL_TYPE_STRING:
                                                 String stringcell=cell.getStringCellValue ()+" ";
                                                 writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
                                                 phrase.add(stringcell);
                                            // document.add(new Phrase(string));
                                                      System.out.print( cell.getStringCellValue () );
                                                      break;
                                                 case HSSFCell.CELL_TYPE_FORMULA:
                                                           String stringdate=cell.getCellFormula()+" ";
                                                           writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
                                                           phrase.add(stringdate);
                                                 System.out.print( cell.getCellFormula() );
                                                           break;
                                                 case HSSFCell.CELL_TYPE_NUMERIC:
                                                 String string=String.valueOf(cell.getNumericCellValue())+" ";
                                                      writer.setSpaceCharRatio(PdfWriter.NO_SPACE_CHAR_RATIO);
                                                      phrase.add(string);
                                                      System.out.print( cell.getNumericCellValue() );
                                                      break;
                                                 default:
                                                      //System.out.println( "unsuported sell type" );
                                                      break;
                                       document.add(new Paragraph(phrase));
                                       document.add(new Paragraph("\n \n \n"));
                   // step 4: we add a paragraph to the document
              } catch (DocumentException de) {
                   System.err.println(de.getMessage());
              } catch (IOException ioe) {
                   System.err.println(ioe.getMessage());
              // step 5: we close the document
              document.close();
    My Input from MS-Excel file is:
         Planning and Tracking Template for Interns                                                                 
         Name of the Intern     N.Kesavulu Reddy                                                            
         Project Name     Enterprise Sales and Marketing                                                            
         Description     Estimated Effort in Hrs     Planned/Replanned          Actual          Actual Effort in Hrs     Complexity     Priority     LOC written new & modified     % work completion     Status     Rework     Remarks
    S.No               Start Date     End Date     Start Date     End Date                                        
    1     setup the configuration          31/01/2005     1/2/2005     31/01/2005     1/2/2005                                        
    2     Deploying an application through Tapestry, Spring, Hibernate          2/2/2005     2/2/2005     2/2/2005     2/2/2005                                        
    3     Gone through Componentization and Cxprice application          3/2/2005     3/2/2005     3/2/2005     3/2/2005                                        
    4     Attend the sessions(tapestry,spring, hibernate), QBA          4/2/2005     4/2/2005     4/2/2005     4/2/2005                                        
         The o/p I'm gettint in .pdf file is:
    Planning and Tracking Template for Interns
    N.Kesavulu Reddy Name of the Intern
    Enterprise Sales and Marketing Project Name
    Remarks Rework Status % work completion LOC written new & modified Priority
    Complexity Actual Effort in Hrs Actual Planned/Replanned Estimated Effort in Hrs Description
    End Date Start Date End Date Start Date S.No
    38354.0 31/01/2005 38354.0 31/01/2005 setup the configuration 1.0
    38385.0 38385.0 38385.0 38385.0 Deploying an application through Tapestry, Spring, Hibernate
    2.0
    38413.0 38413.0 38413.0 38413.0 Gone through Componentization and Cxprice application
    3.0
    38444.0 38444.0 38444.0 38444.0 Attend the sessions(tapestry,spring, hibernate), QBA 4.0
                                       The issues i'm facing are:
    When it is reading a row from MS-Excel it is writing to the .pdf file from last cell to first cell.( 2 cell in 1 place, 1 cell in 2 place like if the row has two cells with data as : Name of the Intern: Kesavulu Reddy then it is writing to the .pdf file as Kesavulu Reddy Name of Intern)
    and the second issue is:
    It is not recognizing the date format..it is recognizing the date in first row only......
    Plz Tell me wht is the solution for this...
    Regards
    [email protected]

    Don't double post your question:
    http://forum.java.sun.com/thread.jspa?threadID=617605&messageID=3450899#3450899
    /Kaj

  • Writing binary to file with 24 or 32-bit numbers

    I am using an NI4472 DAQ to sample some analog data at 24-bits and I want to write the data to disk. However LabView only has a VI to write 16-bit data to disk. Is there a way to write 24 or 32 bit binary numbers to a file?

    The VI you are looking at is probably one of the "Easy VIs" that is setup for a specific application. You can create more general programs to write a binary file with any data type you desire. I would recommend taking a look at the Write Binary File example that ships with LabVIEW. It shows a more general approach to writing data to a binary file. In this example they write double precision numbers but you could easily replace the data with I32s.

  • Writing files with Eclipse over gvfs ends in empty files

    Hello,
    I'm using gvfs to mount folders from our development server. I'm accessing these folders directly with Eclipse. Everything went fine until the last gnome update. Now writing files with Eclipse ends in writing empty files, but there aren't any errors. Eclipse still shows the content of the files until i reopen them.
    When i'm writing files with other apps (vim, gedit) everything works normally?
    Does anybody have any suggestions?
    Thx

    Hello,
    I'm using gvfs to mount folders from our development server. I'm accessing these folders directly with Eclipse. Everything went fine until the last gnome update. Now writing files with Eclipse ends in writing empty files, but there aren't any errors. Eclipse still shows the content of the files until i reopen them.
    When i'm writing files with other apps (vim, gedit) everything works normally?
    Does anybody have any suggestions?
    Thx

  • Writing Datalog Files with record length

    How do I write a Datalog File with a record length of 128 int16s?

    Each I16 number in LabVIEW that you write uses 2 bytes because 8 bits equals 1 byte. If you write 128 numbers, the file will be 256 bytes long. You can modify the VI to write I32 (4 bytes) or I8 (1 byte) just by changing the representation of the number. You also need to change the subVI that does the actual writing (Write File+ [I16].vi). Be sure to rename the VIs that you change. I would think that your Fortran program would work as long as the data types match.

  • Suppress writing cache files with rwrun.exe

    Hello,
    we`re using rwrun.exe (9.0.4.2.0) with parameters to create pdf-files in a loop:
    REPORT=mytest.rdf
    USERID=scott/tiger@orcl
    BLANKPAGES=no
    DESTYPE=file
    DESNAME=mytest.pdf
    DESFORMAT=PDF
    OUTPUTIMAGEFORMAT=GIF
    CACHELOB=NO
    Each process write a cache file in the directory …\reports\cache. Reports eats the hard disk :-(
    I`ve found the EXPIRATION command in the documentation, which defines the point in time when the report output should be deleted from the cache. But this command strictly runs with rwclient.exe and reports server, but Reports server isn`t installed on our server.
    Can we suppress writing cache files with rwrun.exe?
    Steffen

    Hello,
    Why don't you add a command del in your loop ?
    Example:
    del %ORACLE_HOME%\reports\cache\*.*
    Regards

  • Trouble writing to file with FileWriter

    Hey I'm pretty new to Java and even newer to file classes so I'd appreciate it you could look over what I've done. My FlashCard object has its own toString() method which prints out what I want it to so basically all I need to know is why it doesn't print anything?
    File f;
    //..Constructors and other methods for a JFrame
         private void printList() throws IOException
                   writer = new PrintWriter(new BufferedWriter(new FileWriter(f)), true); //f is a File object declared below
                   writer.println("test");
                   java.util.Iterator<FlashCard> e = cards.iterator();
                   String s = "";
                   while(e.hasNext())
                        s = "" + e.next();
                        writer.println(s);          
                        System.out.println(s);   //Debugging line, prints out what i want to be put in the file correctly!
                   writer.close();
                   FileWriter writer2 = new FileWriter(f, true);
                   writer2.write("hi");
    //....more code
    private class ClickListener                          //subclass of the class containing the code above
                   implements ActionListener
                   @Override
                   public void actionPerformed(ActionEvent e)
                        if (e.getSource() == create)
                             boolean temp = false;
                             String fileName = "c:\\FlashCards\\";
                             f = new File(fileName);
                             f.mkdir();
                             f = new File(fileName + stackName.getText() + ".txt");
                             try {
                                  temp = f.createNewFile();
                             } catch (IOException e1) {
                             //...More code here for responding to file not being created successfully
                             f.setWritable(true);
                             control.currentFile = f;
                        }This the the only code I thought to be relevant but if there's a declaration you need that I left out let me know! The annoying thing is I copied this from another class I wrote (with modifications of course) and it works perfectly, no problems!
    Thanks in advance!

    OK I've done the things you've mentioned, thank you for me notice i was missing some code organization. The problem unfortunately is not yet solved but now I think I have a better idea of what the problem is! Here's the code:
    This is what I'm using to make a file
    private void createFile()
                   boolean temp = false;
                   String fileName = "c:\\FlashCards\\";
                   f = new File(fileName);
                   f.mkdir();
                   f = new File(fileName + stackName.getText() + ".txt");
                   try {
                        temp = f.createNewFile();
                   } catch (IOException e1) {
                        //TODO fill in exception catchs
                   if(temp)
                        //Do something
                   else
                        JOptionPane.showMessageDialog(addCard, "File Name Already Exists");
                        return;
              }And this is where the file is being used by a writer:
              private void printList() throws IOException
                   String temp = f.getAbsolutePath();
                   PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(new File(temp), true)), true);
                   java.util.Iterator<FlashCard> i = cards.iterator();
                   while(i.hasNext())
                        writer.println(i.next());          //TODO fix this writer so that it prints properly onto the document!!
                   writer.close();
              }The problem I think is either caused by a) the new File doesn't like properly to the FileWriter for some reason or b) the file I've made does not work for output for some reason. I think this because I can make a new file with a literal pathname such as "c:\\file.txt" and it works fine but as soon as I use my file f to make it it doesn't print anything out!! any ideas?

  • Writing a report file with specific information

    Hi, all:
    I need to write a text file with specific information in it. I'm going to copy it into Excel, so the easier the format, the better (perhaps CSV format?). I've never done this before, so here's the method I need to capture the information from:
         public void step() {
              greenColorStorage = new ArrayList();
              magentaColorStorage = new ArrayList();
              System.out.println( "==> Model step " + getTickCount() );// Checking step #
              for (int i = 0; i < soldierList.size (); i++) {
                   Soldier s = (Soldier) soldierList.get (i);
                   s.step();
              Collections.shuffle(soldierList);
              System.out.println("Shuffling collection now.");
              dsurf.updateDisplay ();
              System.out.println("Model.step() finished.");
              for (int i = 0; i < soldierList.size (); i++) {
                   Soldier s = (Soldier) soldierList.get (i);
                   if (s.getMyColor() == Color.green ) {
                        greenColorStorage.add(s);
                   if (s.getMyColor() == Color.magenta ) {
                        magentaColorStorage.add(s);
              if (magentaColorStorage.size() == 0 || greenColorStorage.size() == 0 ) {
                   stop();
         }In this method, I need to capture this information: There are soldiers on the Green team and on the Magenta team. I need to know how many there are originally, how many in this time step, at what time step the model stops, and how many of the winning color team are left when the model stops. How do I do this? If you can point me to a specific thread that shows how to write a report file like this, I'd be grateful, since I couldn't find one when I searched. Otherwise, I'd be grateful for examples. I'm in the middle of doing some research, and I have the feeling that I'll need to write report files in the future, so if you'd explain any code you provide, I would be quite grateful--I need to understand what I'm doing as well as simply using your code so that I can really learn what I'm doing when I do this again. Thanks very much!

    FileOutputStream
    public FileOutputStream(File file,
                            boolean append)
                     throws FileNotFoundException
    Creates a file output stream to write to the file represented by the specified File object.
    If the second argument is true, then bytes will be written to the end of the file
    rather than the beginning.
    */

Maybe you are looking for