Skip to content

Commit b96c447

Browse files
committed
add pom.xml to README
1 parent da588b1 commit b96c447

File tree

2 files changed

+30
-168
lines changed

2 files changed

+30
-168
lines changed

Diff for: README.md

+30
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
11
# javaToolkit
22
Programming toolkit to avoid reinventing the wheel
3+
4+
# pom.xml
5+
6+
```
7+
<!-- dependencies for javaToolkit -->
8+
<!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
9+
<dependency>
10+
<groupId>commons-io</groupId>
11+
<artifactId>commons-io</artifactId>
12+
<version>2.6</version>
13+
</dependency>
14+
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
15+
<dependency>
16+
<groupId>com.fasterxml.jackson.core</groupId>
17+
<artifactId>jackson-databind</artifactId>
18+
<version>2.10.1</version>
19+
</dependency>
20+
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
21+
<dependency>
22+
<groupId>com.googlecode.json-simple</groupId>
23+
<artifactId>json-simple</artifactId>
24+
<version>1.1</version>
25+
</dependency>
26+
<!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
27+
<dependency>
28+
<groupId>com.google.code.gson</groupId>
29+
<artifactId>gson</artifactId>
30+
<version>2.8.6</version>
31+
</dependency>
32+
```

Diff for: lib/utils/FileUtil.java

-168
Original file line numberDiff line numberDiff line change
@@ -48,173 +48,6 @@ public boolean accept(File current, String name) {
4848
}
4949
});
5050
// System.out.println(Arrays.toString(directories));
51-
<<<<<<< HEAD
52-
return directories;
53-
}
54-
55-
public static String readFile2Str(String fpath) {
56-
String content = "";
57-
try {
58-
content = new String(Files.readAllBytes(Paths.get(fpath)));
59-
} catch (IOException e) {
60-
e.printStackTrace();
61-
}
62-
return content;
63-
64-
}
65-
66-
public static boolean renameDir(String dirPath, String newDirName) {
67-
68-
File dir = new File(dirPath);
69-
if (!dir.isDirectory()) {
70-
System.err.println("There is no directory @ given path");
71-
return false;
72-
} else {
73-
File newDir = new File(dir.getParent() + "/" + newDirName);
74-
dir.renameTo(newDir);
75-
}
76-
return true;
77-
}
78-
79-
public static Boolean writeStr2File(String wStr, String fPath) {
80-
try {
81-
Files.write(Paths.get(fPath), wStr.getBytes());
82-
} catch (IOException e) {
83-
// TODO Auto-generated catch block
84-
e.printStackTrace();
85-
return false;
86-
}
87-
return true;
88-
}
89-
90-
public static boolean deleteDirectory(String dirPath) {
91-
File directoryToBeDeleted = new File(dirPath);
92-
File[] allContents = directoryToBeDeleted.listFiles();
93-
if (allContents != null) {
94-
for (File file : allContents) {
95-
deleteDirectory(file.getAbsolutePath());
96-
}
97-
}
98-
return directoryToBeDeleted.delete();
99-
}
100-
101-
public static void copyFolder(Path srcDirStr, Path destDirStr) {
102-
File source = new File(srcDirStr.toString());
103-
File dest = new File(destDirStr.toString());
104-
try {
105-
FileUtils.copyDirectory(source, dest);
106-
} catch (IOException e) {
107-
e.printStackTrace();
108-
}
109-
}
110-
111-
public static void writeStringToFile(String filePath, String dataStr) {
112-
BufferedWriter bufferedWriter = null;
113-
try {
114-
File file = new File(filePath);
115-
if (!file.exists()) {
116-
file.createNewFile();
117-
}
118-
Writer writer = new FileWriter(file);
119-
bufferedWriter = new BufferedWriter(writer);
120-
bufferedWriter.write(dataStr);
121-
} catch (IOException e) {
122-
e.printStackTrace();
123-
} finally {
124-
try {
125-
if (bufferedWriter != null)
126-
bufferedWriter.close();
127-
} catch (Exception e) {
128-
System.out.println("Write file error!");
129-
e.printStackTrace();
130-
}
131-
}
132-
}
133-
134-
public static String readStringFromFile(String filePath) {
135-
try {
136-
File file = new File(filePath);
137-
if (file.isFile() && file.exists()) {
138-
InputStreamReader read = new InputStreamReader(new FileInputStream(file));
139-
BufferedReader bufferedReader = new BufferedReader(read);
140-
StringBuilder stringBuilder = new StringBuilder();
141-
String line = null;
142-
String ls = System.getProperty("line.separator");
143-
while ((line = bufferedReader.readLine()) != null) {
144-
stringBuilder.append(line);
145-
stringBuilder.append(ls);
146-
}
147-
148-
// delete the last new line separator
149-
stringBuilder.deleteCharAt(stringBuilder.length() - 1);
150-
bufferedReader.close();
151-
152-
String content = stringBuilder.toString();
153-
return content;
154-
} else {
155-
System.out.printf("File not found! %s\n", filePath);
156-
}
157-
} catch (Exception e) {
158-
System.out.println("Read file error!");
159-
e.printStackTrace();
160-
}
161-
return null;
162-
}
163-
164-
public static List<String> readFileToStrList(String filePath) {
165-
ArrayList<String> strList = new ArrayList<String>();
166-
try {
167-
if (!new File(filePath).exists()) {
168-
System.out.println("File not exists! " + filePath);
169-
return null;
170-
}
171-
BufferedReader reader = new BufferedReader(new FileReader(filePath));
172-
String line = reader.readLine();
173-
while (line != null) {
174-
strList.add(line);
175-
line = reader.readLine();
176-
}
177-
reader.close();
178-
} catch (FileNotFoundException e) {
179-
// TODO Auto-generated catch block
180-
System.out.println("filePath : " + filePath);
181-
e.printStackTrace();
182-
} catch (IOException e) {
183-
// TODO: handle exception
184-
System.out.println("filePath : " + filePath);
185-
e.printStackTrace();
186-
}
187-
return strList;
188-
}
189-
190-
public static void createFolder(String dirStr, Boolean deleteIfExist) {
191-
File dir = new File(dirStr);
192-
if (deleteIfExist && dir.exists()) {
193-
deleteDirectory(dir.getAbsolutePath());
194-
dir.mkdirs();
195-
} else if (!dir.exists()) {
196-
dir.mkdirs();
197-
}
198-
}
199-
200-
public static boolean deleteDirectory(File directoryToBeDeleted) {
201-
File[] allContents = directoryToBeDeleted.listFiles();
202-
if (allContents != null) {
203-
for (File file : allContents) {
204-
deleteDirectory(file);
205-
}
206-
}
207-
return directoryToBeDeleted.delete();
208-
}
209-
210-
public static List<String> findFilePathofSpecifcTypeRecusive(String tarDir, String extension) {
211-
212-
List<String> pathList = new ArrayList<String>();
213-
try {
214-
Files.walk(Paths.get(tarDir)).filter(Files::isRegularFile).forEach((f) -> {
215-
String filepath = f.toString();
216-
if (filepath.endsWith(extension))
217-
=======
21851
return directories;
21952
}
22053

@@ -401,7 +234,6 @@ public static List<File> findFilePathofSpecifcTypeRecusive(String tarDir, String
401234
Files.walk(Paths.get(tarDir)).filter(Files::isRegularFile).forEach((f) -> {
402235
String filepath = f.toString();
403236
if (filepath.endsWith(extension))
404-
>>>>>>> 98f658f3ed0bbc9974f52192ded7dd9a43b7f5d7
405237
// System.out.println(file + " found!");
406238
fileList.add(new File(filepath));
407239
});

0 commit comments

Comments
 (0)