Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.crypto.SecretKey;
- import java.io.*;
- import java.lang.*;
- import java.util.*;
- public class CreateFile {
- // Variables
- private Scanner x;
- // Methods
- public void openFile(){
- try{
- x = new Scanner(new File("Students.txt"));
- }
- catch (Exception e){
- System.out.println("You have got an error");
- }
- }
- public void readFile(){
- while(x.hasNext()){
- String name = x.next();
- String surname = x.next();
- String age = x.next();
- System.out.printf("%s %s %s \n", name, surname, age);
- }
- }
- public void closeFile(){
- x.close();
- }
- // Main Function
- public static void main(String[] args){
- CreateFile f = new CreateFile();
- f.openFile();
- f.readFile();
- f.closeFile();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement