Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Public class CountLines(){
- try{
- BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
- System.out.println("Vennligst skriv inn filnavnet og -pathen du vil lagre infoen i:");
- String str = bf.readLine();
- File fil = new File(str);
- if (fil.exists()){
- FileReader fr = new FileReader(fil);
- LineNumberReader ln = new LineNumberReader(fr);
- int antall = 0;
- while (ln.readLine() != null){
- antall++;
- }
- return antall;
- }
- else{
- System.out.println("File does not exists!");
- }
- }
- catch(IOException e){
- e.printStackTrace();
- }
- }
- ID=CountLines();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement