Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TeeTime-Framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nelson Tavares de Sousa
TeeTime-Framework
Commits
f365bd84
Commit
f365bd84
authored
10 years ago
by
Nelson Tavares de Sousa
Browse files
Options
Downloads
Patches
Plain Diff
first version which searches in the classpath the given file and merges
all files into one
parent
12d2890a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/java/teetime/framework/FileSearcher.java
+18
-10
18 additions, 10 deletions
src/main/java/teetime/framework/FileSearcher.java
src/main/java/teetime/framework/pipe/PipeFactoryLoader.java
+43
-0
43 additions, 0 deletions
src/main/java/teetime/framework/pipe/PipeFactoryLoader.java
with
61 additions
and
10 deletions
src/main/java/teetime/framework/FileSearcher.java
+
18
−
10
View file @
f365bd84
package
teetime.framework
;
import
java.io.IOException
;
import
java.util.StringTokenizer
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.Enumeration
;
import
java.util.List
;
import
teetime.framework.pipe.PipeFactoryLoader
;
public
class
FileSearcher
{
public
static
void
main
(
final
String
[]
args
)
throws
IOException
{
final
String
classpath
=
System
.
getProperty
(
"java.class.path"
);
final
String
pathSeparator
=
System
.
getProperty
(
"path.separator"
);
// System.out.println(classpath);
// System.out.println(pathSeparator);
StringTokenizer
st
=
new
StringTokenizer
(
classpath
,
pathSeparator
);
while
(
st
.
hasMoreTokens
())
{
System
.
out
.
println
(
st
.
nextToken
());
// st.nextToken());
}
PipeFactoryLoader
.
mergeConfigFiles
(
"LICENSE.txt"
,
"test.txt"
);
}
public
static
List
<
URL
>
loadResources
(
final
String
name
)
throws
IOException
{
final
List
<
URL
>
list
=
new
ArrayList
<
URL
>();
final
Enumeration
<
URL
>
systemRes
=
ClassLoader
.
getSystemClassLoader
().
getResources
(
name
);
while
(
systemRes
.
hasMoreElements
())
{
list
.
add
(
systemRes
.
nextElement
());
}
return
list
;
}
}
This diff is collapsed.
Click to expand it.
src/main/java/teetime/framework/pipe/PipeFactoryLoader.java
+
43
−
0
View file @
f365bd84
package
teetime.framework.pipe
;
import
java.io.BufferedReader
;
import
java.io.File
;
import
java.io.FileNotFoundException
;
import
java.io.FileOutputStream
;
import
java.io.FileReader
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.URL
;
import
java.util.LinkedList
;
import
java.util.List
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
teetime.framework.FileSearcher
;
import
com.google.common.io.ByteStreams
;
import
com.google.common.io.Files
;
public
class
PipeFactoryLoader
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
PipeFactoryLoader
.
class
);
...
...
@@ -46,4 +56,37 @@ public class PipeFactoryLoader {
return
pipeFactories
;
}
public
static
void
mergeConfigFiles
(
final
String
configFileName
,
final
String
mergedFileName
)
{
File
output
=
new
File
(
mergedFileName
);
FileOutputStream
os
;
try
{
os
=
new
FileOutputStream
(
output
);
}
catch
(
FileNotFoundException
e1
)
{
throw
new
IllegalStateException
(
e1
);
}
try
{
Files
.
touch
(
output
);
}
catch
(
IOException
e
)
{
throw
new
IllegalStateException
(
e
);
}
List
<
URL
>
files
=
null
;
try
{
files
=
FileSearcher
.
loadResources
(
configFileName
);
}
catch
(
IOException
e
)
{
throw
new
IllegalStateException
(
e
);
}
for
(
URL
url
:
files
)
{
try
{
InputStream
is
=
url
.
openStream
();
ByteStreams
.
copy
(
is
,
os
);
is
.
close
();
}
catch
(
IOException
e
)
{
throw
new
IllegalStateException
(
e
);
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment