DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2008
    Posts
    14

    Binary file problem

    I am writing to a binary file. My poblem is that i want that the next time it write to the file it will write on a new line. What can i do? Thanks a lot.

    This is the piece of code that writes to the file:

    Code:
                         File aFile  = new File( "players.dat" );
                         // create an output stream to the file
                         FileOutputStream aFileOutStream = new FileOutputStream ( aFile, true );
                         // create a data output stream to the file output stream
                         DataOutputStream aDataOutStream = new DataOutputStream ( aFileOutStream );
                         // write data to file
                         aDataOutStream.writeUTF(player);
                         aDataOutStream.writeUTF(String.valueOf(percent) );
                         aDataOutStream.writeUTF(type );
    
                         aFileOutStream.close();

  2. #2
    Join Date
    Apr 2007
    Location
    Sterling Heights, Michigan
    Posts
    8,651
    Append a carriage return/line feed to each line.
    I don't answer coding questions via PM or Email. Please post a thread in the appropriate forum section.
    Please use [Code]your code goes in here[/Code] tags when posting code.
    Before posting your question, did you look here?
    Got a question on Linux? Visit our Linux sister site.
    Modifications Required For VB6 Apps To Work On Vista

  3. #3
    Join Date
    Feb 2008
    Posts
    14
    Ok thanks a lot. :-)

  4. #4
    Join Date
    Dec 2004
    Location
    San Bernardino County, California
    Posts
    1,468
    Writing to a file is just like writing to the console: you are manipulating a stream of data.

Similar Threads

  1. problem in reading unicode text file
    By jitendrapatel in forum C++
    Replies: 1
    Last Post: 04-21-2005, 05:26 PM
  2. File creation problem
    By Michael in forum ASP.NET
    Replies: 2
    Last Post: 04-18-2005, 12:30 PM
  3. Problem creating XML file
    By gia in forum XML
    Replies: 4
    Last Post: 06-28-2001, 01:35 PM
  4. NullPointerException when reading text file
    By Andrew McLellan in forum Java
    Replies: 3
    Last Post: 05-09-2001, 05:34 PM
  5. "Suspected" DataBase - problem with Log file
    By Nirit Touboul in forum Database
    Replies: 0
    Last Post: 04-01-2001, 07:37 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links