Skip to content

Commit d9db3eb

Browse files
committed
Merge remote-tracking branch 'origin/main'
# Conflicts: # src/main/java/omegaui/io/storage/FileUtils.java
2 parents e4ca58f + e5768a8 commit d9db3eb

File tree

1 file changed

+14
-17
lines changed

1 file changed

+14
-17
lines changed

src/main/java/omegaui/io/storage/FileUtils.java

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
/**
22
* Common FileUtils.
3-
*
43
* @author: omegaui
54
* Copyright (C) 2023 Omega UI
6-
* <p>
5+
76
* This program is free software: you can redistribute it and/or modify
87
* it under the terms of the GNU General Public License as published by
98
* the Free Software Foundation, either version 3 of the License, or
109
* (at your option) any later version.
11-
* <p>
10+
1211
* This program is distributed in the hope that it will be useful,
1312
* but WITHOUT ANY WARRANTY; without even the implied warranty of
1413
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1514
* GNU General Public License for more details.
16-
* <p>
15+
1716
* You should have received a copy of the GNU General Public License
1817
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1918
*/
@@ -35,45 +34,43 @@ public class FileUtils {
3534
* @param paths array of path
3635
* @return path
3736
*/
38-
public static String join(String... paths) {
37+
public static String join(String... paths){
3938
StringBuilder result = new StringBuilder();
40-
for (String path : paths) {
39+
for(String path : paths){
4140
result.append(path).append(File.separator);
4241
}
4342
return result.substring(0, result.length() - 1);
4443
}
45-
4644
/**
4745
* Reads and returns the content of a text file.
4846
* @param file File Object
4947
* @return String contents
5048
*/
51-
public static String read(File file) {
52-
if (!file.exists()) {
49+
public static String read(File file){
50+
if(!file.exists()){
5351
return null;
5452
}
55-
StringBuilder content = new StringBuilder();
53+
String content = "";
5654
try (Scanner reader = new Scanner(file)) {
57-
while (reader.hasNextLine()) {
58-
content.append(reader.nextLine()).append("\n");
55+
while(reader.hasNextLine()){
56+
content += reader.nextLine() + "\n";
5957
}
6058
} catch (FileNotFoundException e) {
6159
throw new RuntimeException(e);
6260
}
63-
return content.toString();
61+
return content;
6462
}
65-
6663
/**
6764
* Writes content to a text file.
6865
* Returns true on successful write operation.
6966
* @param file File Object
7067
* @param content content of the file
7168
* @return boolean
7269
*/
73-
public static boolean write(File file, String content) {
70+
public static boolean write(File file, String content){
7471
File parent = file.getParentFile();
75-
if (parent != null) {
76-
if (!parent.mkdirs()) {
72+
if(parent != null) {
73+
if(!parent.mkdirs()){
7774
System.err.println("Cannot construct the parent directories: " + file);
7875
return false;
7976
}

0 commit comments

Comments
 (0)