Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CountMostImport/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions CountMostImport/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>CountMostImport</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions CountMostImport/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Binary file added CountMostImport/bin/CountMostImport.class
Binary file not shown.
76 changes: 76 additions & 0 deletions CountMostImport/src/CountMostImport.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class CountMostImport {
private static Map<String, Integer> out = new HashMap<String, Integer>();
public static void main(){
String path = "";
File new_file = new File(path);
DepthSearch(new_file, out);
CountMostImport10(out);
}



private static void DepthSearch(File s, Map<String, Integer> out){
if(s.isDirectory()){
File[] files = s.listFiles();
if(files.length != 0){
for(File file:files){
DepthSearch(file,out);
}
}
}
else{
try{
CalImport(s, out);
}catch(Exception ex){
System.out.println("error reading files!");
}

}

}

private static void CalImport(File file, Map<String, Integer> out) throws IOException{
BufferedReader in = new BufferedReader(new FileReader(file));
String read_string;
while((read_string = in.readLine()) != null){
if(read_string.startsWith("package")){
continue;
}
if(read_string.startsWith("import")){
String m_s = read_string.replaceAll("\\.", " ");
String regex = "import .+?(\\S+);";
Matcher matcher = Pattern.compile(regex).matcher(m_s);
matcher.find();
Integer count = out.get(matcher.group(1));
if(count == null){
out.put(matcher.group(1), 1);
}else{
out.put(matcher.group(1), count++);
}
}
else break;
}

}

private static void CountMostImport10(Map<String, Integer> out){
int count = 0 ;
for(String i: out.keySet())
{
if(count == 10)
break;
System.out.println(i + ":" + out.get(i));
count++;
}

}

}
Binary file added EffectiveLines/.DS_Store
Binary file not shown.
Binary file added EffectiveLines/EffectiveLines.class
Binary file not shown.
37 changes: 37 additions & 0 deletions EffectiveLines/EffectiveLines.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import java.util.*;
import java.io.*;

public class EffectiveLines
{
public static void main(String[] args)throws IOException
{
System.out.println(read("test.java"));
}
public static String read(String filename) throws IOException
{
BufferedReader in = new BufferedReader(new FileReader(filename));
String s;
int result = 0;
boolean comment = false;

while((s = in.readLine()) != null)
{
s = s.trim();
if(s.matches("^[//s&&[^//n]]*$")) {
continue;
}
else if(s.startsWith("/*") && !s.endsWith("*/")) {
comment = true;
}else if (true == comment){
if (s.endsWith("*/")) {
comment = false;
}
}else if(s.startsWith("//")) {
continue;
}else{
result++;
}
}
return Integer.toString(result);
}
}
Binary file added ExchangeRate/.DS_Store
Binary file not shown.
39 changes: 39 additions & 0 deletions ExchangeRate/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="lib" path="/Users/daqian/Documents/workspace/work2/src/jsoup-1.9.2.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/httpcomponents-client-4.5.2/lib/httpclient-4.5.2.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/httpcomponents-client-4.5.2/lib/commons-codec-1.9.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/httpcomponents-client-4.5.2/lib/commons-logging-1.2.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/httpcomponents-client-4.5.2/lib/fluent-hc-4.5.2.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/httpcomponents-client-4.5.2/lib/httpclient-cache-4.5.2.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/httpcomponents-client-4.5.2/lib/httpclient-win-4.5.2.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/httpcomponents-client-4.5.2/lib/httpcore-4.4.4.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/httpcomponents-client-4.5.2/lib/httpmime-4.5.2.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/httpcomponents-client-4.5.2/lib/jna-4.1.0.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/httpcomponents-client-4.5.2/lib/jna-platform-4.1.0.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/commons-codec-1.10.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/commons-io-2.5.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/commons-lang3-3.4.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/commons-logging-1.2.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/cssparser-0.9.19.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/htmlunit-2.22.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/htmlunit-core-js-2.22.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/httpclient-4.5.2.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/httpcore-4.4.4.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/httpmime-4.5.2.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/jetty-io-9.2.17.v20160517.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/jetty-util-9.2.17.v20160517.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/neko-htmlunit-2.21.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/sac-1.3.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/serializer-2.7.2.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/websocket-api-9.2.17.v20160517.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/websocket-client-9.2.17.v20160517.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/websocket-common-9.2.17.v20160517.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/xalan-2.7.2.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/xercesImpl-2.11.0.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/htmlunit-2.22/lib/xml-apis-1.4.01.jar"/>
<classpathentry kind="lib" path="/Users/daqian/Downloads/jexcelapi/jxl.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
17 changes: 17 additions & 0 deletions ExchangeRate/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>work2</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
11 changes: 11 additions & 0 deletions ExchangeRate/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
org.eclipse.jdt.core.compiler.debug.localVariable=generate
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.8
Binary file added ExchangeRate/bin/.DS_Store
Binary file not shown.
Binary file added ExchangeRate/bin/work2/my_work.class
Binary file not shown.
Binary file added ExchangeRate/out.xls
Binary file not shown.
Binary file added ExchangeRate/src/.DS_Store
Binary file not shown.
Binary file added ExchangeRate/src/work2/commons-codec-1.10.jar
Binary file not shown.
Binary file added ExchangeRate/src/work2/commons-io-2.5.jar
Binary file not shown.
Binary file added ExchangeRate/src/work2/commons-lang3-3.4.jar
Binary file not shown.
Binary file added ExchangeRate/src/work2/commons-logging-1.2.jar
Binary file not shown.
Binary file added ExchangeRate/src/work2/cssparser-0.9.19.jar
Binary file not shown.
Binary file added ExchangeRate/src/work2/htmlunit-2.22.jar
Binary file not shown.
Binary file added ExchangeRate/src/work2/htmlunit-core-js-2.22.jar
Binary file not shown.
Binary file added ExchangeRate/src/work2/httpclient-4.5.2.jar
Binary file not shown.
Binary file added ExchangeRate/src/work2/httpcore-4.4.4.jar
Binary file not shown.
Binary file added ExchangeRate/src/work2/httpmime-4.5.2.jar
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added ExchangeRate/src/work2/jsoup-1.9.2.jar
Binary file not shown.
Binary file added ExchangeRate/src/work2/jxl.jar
Binary file not shown.
Loading