Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

File System Write

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello folks,

I am writing an application in which I need to write into a file some information like:

Master file Account number Name Balance
100 Alan Jones 348.17
300 Mary Smith 27.19
500 Sam Sharp 0.00

One row for each record, again when an user require to access his accounts he may enter his account number and the related records will be fetch, thats why I want to insert each record with the help of row and column.

Here is my code for to write into a file.:

import java.io.*;

class ProgramTest
{
int a_num;
int t_amt;


public static void main(String[] a) throws IOException
{
ProgramTest object = new ProgramTest();

BufferedWriter out=null;

try
{
File file = new File("oldmast.txt");
File file1 = new File("trans.txt");

// Create file if it does not exist

if (file.createNewFile())
{
// File did not exist and was created
System.out.println("oldmast.txt Created Successfully");
}
else
{
System.out.println("oldmast.txt already exists");
}

if (file1.createNewFile())
{
// File did not exist and was created
System.out.println("trans.txt Created Successfully");
}
else
{
System.out.println("trans.txt already exists");
}


TransactionRecord obj=new TransactionRecord();
object=obj.retrieve(object);

out = new BufferedWriter(new FileWriter("oldmast.txt",true));
out.write(String.valueOf(object.a_num));
out.write(String.valueOf(object.t_amt));

}
catch (IOException e)
{
}
finally
{
out.close();
}
}
}



What will I do to use the rows and columns kind of format, please help me out, I am relatively new in the java file system.

please help!

Thanking you all friends.
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
Grow your own food... or this tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic