📄 loc.java
字号:
/*
* Created on 2004/09/28
*
*/
package za.co.halo.SecureCommunications.util;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.filechooser.FileFilter;
public class LOC {
LOC()
{
File f = new File("C:\\programming\\java\\HaloMail\\");
System.out.println("LOC="+getLOC(f));
}
public int getLOC(File f)
{
System.out.println(f.getAbsolutePath());
File[] files = f.listFiles();
int loc = 0;
if (files != null)
for (File file:files)
{
if (file.getName().startsWith(".") || file.getName().startsWith("CVS"))
continue;
if (file.isDirectory())
loc += getLOC(file);
else if (file.getName().endsWith(".java"))
loc += getLOCForFile(file);
}
return loc;
}
private int getLOCForFile(File f)
{
int loc = 0;
try {
BufferedReader read = new BufferedReader(new FileReader(f));
while (read.ready())
{
String s = read.readLine().trim();
if (s!=null && !s.equals("") && !s.startsWith("//"))
loc++;
}
read.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return loc;
}
/**
* @param args
*/
public static void main(String[] args) {
new LOC();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -