Here you can find the source of countFileLines(Scanner fin)
Parameter | Description |
---|---|
fin | a parameter |
public static int countFileLines(Scanner fin)
//package com.java2s; /*/*from www .ja v a 2 s . com*/ *@author Grant Callant *My FileUtil Class to open and read *as well as open and write files, user specified, and *string literal file names. * * Copyright 2015 Grant Callant Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ import java.util.Scanner; public class Main { /** * Counts the number of lines that are in an input file. * @param fin * @return the number of lines in the file */ public static int countFileLines(Scanner fin) { int count = 0; while (fin.hasNext()) { count++; fin.nextLine(); } return count; } }