Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.*;
- public class BytePe3 {
- ArrayList<Integer> numbers = new ArrayList<Integer>();
- int part1 = 0;
- int counter = 0;
- int sum = 0;
- int numberOfFiles = 0;
- public static void main(String[] args) {
- BytePe3 p3 = new BytePe3();
- for(int n = 1; n <= 8; n++) {
- String xd = "integer"+n+".dat";
- File rawr = new File(xd);
- BytePe3.ReadInts i1 = p3.new ReadInts(rawr);
- }
- }
- class ReadInts implements Runnable {
- File abc;
- public ReadInts(File _fileName) {
- abc =_fileName;
- }
- public void run() {
- try {
- if(abc.exists() != true) {
- System.out.println("File doesn't exist!");
- } else {
- FileInputStream fis = new FileInputStream(abc);
- DataInputStream dis = new DataInputStream(fis);
- while(dis.available() > 0) {
- part1 = dis.readInt();
- numbers.add(part1);
- sum += part1;
- counter++;
- }
- @SuppressWarnings("unused")
- int totalSize = 0;
- for(int x = 0; x < numberOfFiles; x++) {
- totalSize = numbers.size();
- }
- dis.close();
- System.out.println("Filename= "+abc+" Count = "+counter+" sum = "+sum+" In List = "+numbers.size());
- counter = 0;
- sum = 0;
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment