Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
heeeeeyy
我的代码库
提交
d8d7cdbd
我
我的代码库
项目概览
heeeeeyy
/
我的代码库
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
我
我的代码库
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
d8d7cdbd
编写于
3月 14, 2023
作者:
heeeeeyy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
上传新文件
上级
fc5949a1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
64 addition
and
0 deletion
+64
-0
src/com/bluelake/Main.java
src/com/bluelake/Main.java
+64
-0
未找到文件。
src/com/bluelake/Main.java
0 → 100644
浏览文件 @
d8d7cdbd
package
com.bluelake
;
import
com.bluelake.utils.LevenshteinAlgorithm
;
import
java.io.*
;
import
java.text.SimpleDateFormat
;
import
java.util.Scanner
;
public
class
Main
{
static
final
String
ENCODING
=
"utf-8"
;
static
final
String
ANSWER_FILE
=
"D:\\text\\Article_repetition_answer.txt"
;
public
static
void
main
(
String
[]
args
)
{
Scanner
sc
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"请输入原论文的地址:"
);
String
aAddress
=
sc
.
nextLine
();
System
.
out
.
println
(
"请输入抄袭论文的地址:"
);
String
bAddress
=
sc
.
nextLine
();
String
a
=
readFile
(
aAddress
);
String
b
=
readFile
(
bAddress
);
System
.
out
.
println
(
"论文查重结果已经存储在"
+
ANSWER_FILE
);
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
result
=
df
.
format
(
System
.
currentTimeMillis
())+
"\n"
+
aAddress
+
"与"
+
bAddress
+
"的相似度为 : "
+
String
.
format
(
"%.3f"
,
LevenshteinAlgorithm
.
Levenshtein
(
a
,
b
)*
100
)+
"%"
;
writeAnswer
(
result
);
System
.
out
.
println
(
result
);
}
static
public
String
readFile
(
String
path
)
{
File
file
=
new
File
(
path
);
try
{
InputStreamReader
inputStreamReader
=
new
InputStreamReader
(
new
FileInputStream
(
file
),
ENCODING
);
BufferedReader
bufferedReader
=
new
BufferedReader
(
inputStreamReader
);
if
(
file
.
isFile
()
&&
file
.
exists
())
{
String
line
;
StringBuilder
stringBuilder
=
new
StringBuilder
();
while
((
line
=
bufferedReader
.
readLine
())
!=
null
)
{
stringBuilder
.
append
(
line
);
}
return
stringBuilder
.
toString
();
}
else
{
System
.
out
.
println
(
"该输入文件不存在"
);
}
inputStreamReader
.
close
();
}
catch
(
Exception
e
)
{
System
.
out
.
println
(
"文件读取失败"
);
}
return
null
;
}
static
public
void
writeAnswer
(
String
str
)
{
File
answer_file
=
new
File
(
ANSWER_FILE
);
if
(!
answer_file
.
exists
()){
try
{
answer_file
.
createNewFile
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}}
byte
[]
bytes
=
str
.
getBytes
();
int
b
=
bytes
.
length
;
FileOutputStream
fileOutputStream
;
try
{
fileOutputStream
=
new
FileOutputStream
(
answer_file
);
fileOutputStream
.
write
(
bytes
,
0
,
b
);
fileOutputStream
.
close
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录