Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package datastorage;
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- public class ReadData {
- public static void readData() {
- int n = 0;
- SolidStateDrive[] ssd = new SolidStateDrive[n+1];
- try {
- BufferedReader br = new BufferedReader(new FileReader("SSD.txt"));
- String line = null;
- while((line = br.readLine()) != null) {
- String tmp[] = line.split("\t");
- ssd[n] = new SolidStateDrive();
- ssd[n].brand = tmp[0];
- ssd[n].model = tmp[1];
- ssd[n].capacityInGB = Integer.parseInt(tmp[2]);
- n++;
- }
- br.close();
- for (int j=0; j<=n; j++) {
- System.out.println(j+ "\t" +ssd[j].brand+ "\t" +ssd[j].model+ "\t" +ssd[j].capacityInGB);
- }
- } catch(IOException ex) {
- ex.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement