Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileReader;
import java.io.IOException;

import java.io.LineNumberReader;

public class Main {
    public static int getLineCount(String path) {
        LineNumberReader lnr = null;
        try {
            lnr = new LineNumberReader(new FileReader(new File(path)));
            lnr.skip(Long.MAX_VALUE);
        } catch (FileNotFoundException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        if (lnr == null)
            return 0;
        return lnr.getLineNumber();
    }
}