Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Cyril Labbe
scidetect
Commits
f3296cb9
Commit
f3296cb9
authored
Jun 22, 2015
by
Tien
Browse files
add cleaner to delete generated txt after
parent
2117fc3b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/fr/imag/forge/scidetect/Checker/Cleaner.java
0 → 100644
View file @
f3296cb9
/*
* Copyright (C) 2015 UNIVERSITE JOSEPH FOURIER (Grenoble 1)/ Springer-Verlag GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package
fr.imag.forge.scidetect.Checker
;
import
fr.imag.forge.scidetect.Corpus.Text
;
import
fr.imag.forge.scidetect.Corpus.TextProcessor
;
import
java.io.File
;
import
java.util.ArrayList
;
/**
* Clean generated txt after processing
*
* @author Nguyen Minh Tien - minh-tien.nguyen@imag.fr
*/
public
class
Cleaner
{
public
void
clean
(
String
foldername
)
{
File
folder
=
new
File
(
foldername
);
if
(
folder
.
isDirectory
())
{
File
[]
listOfFile
=
folder
.
listFiles
();
for
(
int
j
=
0
;
j
<
listOfFile
.
length
;
j
++)
{
if
(
listOfFile
[
j
].
isDirectory
())
{
clean
(
listOfFile
[
j
].
getPath
());
}
else
if
(
listOfFile
[
j
].
getName
().
endsWith
(
".pdf"
)
||
listOfFile
[
j
].
getName
().
endsWith
(
".xml"
)
||
listOfFile
[
j
].
getName
().
endsWith
(
".xtx"
))
{
String
originalname
=
listOfFile
[
j
].
getName
();
String
originalnamewoextension
=
listOfFile
[
j
].
getName
().
substring
(
0
,
listOfFile
[
j
].
getName
().
lastIndexOf
(
"."
));
for
(
int
i
=
0
;
i
<
listOfFile
.
length
;
i
++)
{
if
(
listOfFile
[
i
].
getName
().
contains
(
originalnamewoextension
)
&&
!
listOfFile
[
i
].
getName
().
contains
(
originalname
))
{
listOfFile
[
i
].
delete
();
}
}
}
}
}
else
if
(
folder
.
getName
().
endsWith
(
".pdf"
)
||
folder
.
getName
().
endsWith
(
".xml"
)
||
folder
.
getName
().
endsWith
(
".xtx"
))
{
String
originalname
=
folder
.
getName
();
File
[]
listOfFile
=
folder
.
getParentFile
().
listFiles
();
String
originalnamewoextension
=
folder
.
getName
().
substring
(
0
,
folder
.
getName
().
lastIndexOf
(
"."
));
for
(
int
i
=
0
;
i
<
listOfFile
.
length
;
i
++)
{
if
(
listOfFile
[
i
].
getName
().
contains
(
originalnamewoextension
)
&&
!
listOfFile
[
i
].
getName
().
contains
(
originalname
))
{
listOfFile
[
i
].
delete
();
}
}
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment