TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
SUNIL GUTTA
NA
1k
395.4k
code correction @no of lines in file ? just one line
Oct 28 2013 3:56 AM
Hi
Question
:
Write a Java program that process and determines the number of lines in a file.
Please look at the below code .. at
while(args[i] != null)
i am getting continuous
exception
import java.io.*;
class cntlines
{
public static void main(String args[]) throws IOException
{
Try
{
FileReader fr;
BufferedReader br;
File f;
String str;
int i=0,cnt=0;
while(args[i] != null)
{
f = new File(args[i]);
fr = new FileReader(f);
br = new BufferedReader(fr);
while((str = br.readLine()) != null)
cnt++;
System.out.println("File Name : " + f.getName() + " Total Lines : " + cnt);
cnt = 0;
i++;
fr.close();
}
}
catch(FileNotFoundException e)
{
System.out.println("File Not Found");
}
catch(IOException e)
{
System.out.println("Exception : " + e);
}
}
}
cheers ty ..
Reply
Answers (
1
)
reversing the strings in different ways ?
How can export data in excel from MYSql server.