File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes How can i browse 3 files (same file format, exp: .txt) and process it ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How can i browse 3 files (same file format, exp: .txt) and process it ?" Watch "How can i browse 3 files (same file format, exp: .txt) and process it ?" New topic
Author

How can i browse 3 files (same file format, exp: .txt) and process it ?

motress zlting
Ranch Hand

Joined: Jan 10, 2010
Posts: 55
How can i browse 3 files (same file format, exp: .txt) ,process and output it in one ?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Did you try something ? Can you read one file ?


[My Blog]
All roads lead to JavaRanch
motress zlting
Ranch Hand

Joined: Jan 10, 2010
Posts: 55
Christophe Verré wrote:Did you try something ? Can you read one file ?


ya, i can read and process one file but i don't know how to do multiple file .....
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

If you can read one, you can read three, can't you ? A basic algorithm could be :

1. Open output file
2. For each input file
2.1 Open input file
2.2 Until input data left
2.2.1 Read input file
2.2.2 Output data
2.3 Close input file
3. Close output file
motress zlting
Ranch Hand

Joined: Jan 10, 2010
Posts: 55
Christophe Verré wrote:If you can read one, you can read three, can't you ? A basic algorithm could be :

1. Open output file
2. For each input file
2.1 Open input file
2.2 Until input data left
2.2.1 Read input file
2.2.2 Output data
2.3 Close input file
3. Close output file


Now i can ,
1.open file
2.read and process file
3.output data

but i wan,
1.open first file (.txt)
1.1open second file (.txt)
1.2open third file (.txt)
2.read all three file and process
3.output data in a textpad

Thanks
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

No matter how the algorithm looks like, if you can read one file, you can read three ! Show us the code you have so far.
motress zlting
Ranch Hand

Joined: Jan 10, 2010
Posts: 55
Christophe Verré wrote:No matter how the algorithm looks like, if you can read one file, you can read three ! Show us the code you have so far.


ok,
the fileread.txt is calculate the average , the filechoose.txt is UI to open file....



@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


motress zlting
Ranch Hand

Joined: Jan 10, 2010
Posts: 55
sample log file

#PlacelabStumbler Log Version 2
TYPE=TIMEOUT
TYPE=WIFI|TIME=1263867778390|ID=00:24:c3:31:2b:e0|NAME=csusm|RSSI=-93|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:12:17:7b:33:04|NAME=csusm|RSSI=-80|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:1f:27:55:f7:70|NAME=USMHotspot|RSSI=-70|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:1e:13:ee:3e:40|NAME=USMHotspot|RSSI=-85|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:24:c3:31:b8:80|NAME=csusm|RSSI=-91|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:90:4c:60:04:02|NAME=csusm|RSSI=-94|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:1b:0d:d6:6d:50|NAME=USMHotspot|RSSI=-70|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:1a:a2:dc:a0:60|NAME=USMHotspot|RSSI=-86|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867778390|ID=00:1e:c1:4c:c5:ce|NAME=3Com|RSSI=-94|WEP=true|INFR=true
TYPE=TIMEOUT
TYPE=WIFI|TIME=1263867780390|ID=00:24:c3:31:b8:80|NAME=csusm|RSSI=-91|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867780390|ID=00:1e:c1:4c:c5:ce|NAME=3Com|RSSI=-94|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867780390|ID=00:1a:a2:dc:a0:60|NAME=USMHotspot|RSSI=-91|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867780390|ID=00:1f:27:55:f7:70|NAME=USMHotspot|RSSI=-82|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867780390|ID=00:12:17:7b:33:04|NAME=csusm|RSSI=-80|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867780390|ID=00:90:4c:60:04:02|NAME=csusm|RSSI=-89|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867780390|ID=00:1b:0d:d6:6d:50|NAME=USMHotspot|RSSI=-82|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867780390|ID=00:24:c3:31:2b:e0|NAME=csusm|RSSI=-93|WEP=true|INFR=true
TYPE=TIMEOUT
TYPE=WIFI|TIME=1263867782390|ID=00:1e:c1:4c:c5:ce|NAME=3Com|RSSI=-94|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867782390|ID=00:24:c3:31:b8:80|NAME=csusm|RSSI=-91|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867782390|ID=00:1a:a2:dc:a0:60|NAME=USMHotspot|RSSI=-83|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867782390|ID=00:12:17:7b:33:04|NAME=csusm|RSSI=-80|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867782390|ID=00:1f:27:55:f7:70|NAME=USMHotspot|RSSI=-80|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867782390|ID=00:1b:0d:d6:6d:50|NAME=USMHotspot|RSSI=-65|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867782390|ID=00:90:4c:60:04:02|NAME=csusm|RSSI=-77|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867782390|ID=00:24:c3:31:2b:e0|NAME=csusm|RSSI=-93|WEP=true|INFR=true
TYPE=TIMEOUT
TYPE=WIFI|TIME=1263867784390|ID=00:1e:c1:4c:c5:ce|NAME=3Com|RSSI=-90|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867784390|ID=00:1a:a2:dc:a0:60|NAME=USMHotspot|RSSI=-83|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867784390|ID=00:1f:27:55:f7:70|NAME=USMHotspot|RSSI=-62|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867784390|ID=00:24:c3:31:0f:e0|NAME=csusm|RSSI=-87|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867784390|ID=00:1b:0d:d6:6d:50|NAME=USMHotspot|RSSI=-86|WEP=true|INFR=true
TYPE=WIFI|TIME=1263867784390|ID=00:90:4c:60:04:02|NAME=csusm|RSSI=-79|WEP=true|INFR=true
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

aaahh, you were talking about a JFileSelector... In your FileChooserDemo#actionPerformed, you could show the file selector three times, and retrieve the selected file each time, then process each file.

if (e.getSource() == openButton) {
1. Loop until three file selected
1.1 Show file selector
1.2 Store selected file (e.g. in an array)
2. Loop each file and process
motress zlting
Ranch Hand

Joined: Jan 10, 2010
Posts: 55
Christophe Verré wrote:aaahh, you were talking about a JFileSelector... In your FileChooserDemo#actionPerformed, you could show the file selector three times, and retrieve the selected file each time, then process each file.

if (e.getSource() == openButton) {
1. Loop until three file selected
1.1 Show file selector
1.2 Store selected file (e.g. in an array)
2. Loop each file and process



If say that i want to combine the data in those three selected file first then only process it ,can it works ? Any method to do that ?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

Yes, you can read each file and store each line (fileScanner.nextLine()) in an array or a list.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How can i browse 3 files (same file format, exp: .txt) and process it ?