aspose file tools*
The moose likes I/O and Streams and the fly likes Dynamically reading a file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Dynamically reading a file" Watch "Dynamically reading a file" New topic
Author

Dynamically reading a file

mayank gupta
Ranch Hand

Joined: Dec 21, 2008
Posts: 78
Hello,

I have a shell script which populates records in a flat file. I have a java program that has to read in those records and process them.

File file = new File("test");
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
String cdr = null;

try {
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);

while (dis.available() != 0) {
cdr = dis.readLine();
(new Thread(new CreditCalculator(cdr))).start();
//thread1.start();
System.out.println("One thread started "+cdr);
}System.out.println("Ended while loop\n");
mayank gupta
Ranch Hand

Joined: Dec 21, 2008
Posts: 78
I'm sorry i sent it by mistake before i could complete the post.

I have a shell script which populates records in a flat file. I have a java program that has to read in those records and process them.

File file = new File("test");
FileInputStream fis = null;
BufferedInputStream bis = null;
DataInputStream dis = null;
String cdr = null;

try {
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
dis = new DataInputStream(bis);

while (dis.available() != 0) {
cdr = dis.readLine();
(new Thread(new CreditCalculator(cdr))).start();
}

My flat file gets populated on and off but the issue is that once i run the class it does not read the updated flat file. Will I have to load the file again? How can I do it?

Please help.

Thank You.
Mayank.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39548
    
  27
Part of the problem may be that AvailableDoesntDoWhatYouThinkItDoes.


Ping & DNS - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamically reading a file
 
Similar Threads
how to read line by line and pass each line value to a method
How can I use StringBuffer in this case...
writing data to CSV file
how exactly can i make out if a file in linux has just been updated or has been replaced.
Reading Data from a file and extracting the data