Skip to content

Commit 383e94a

Browse files
committed
Started making the database startup application.
1 parent 4654297 commit 383e94a

File tree

8 files changed

+265
-159
lines changed

8 files changed

+265
-159
lines changed

.idea/libraries/Maven__commons_io_commons_io_1_3_2.xml

+13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+58-58
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

system-setup/pom.xml

+18
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@
2121
<artifactId>commons-vfs2</artifactId>
2222
<version>2.0</version>
2323
</dependency>
24+
<dependency>
25+
<groupId>org.apache.commons</groupId>
26+
<artifactId>commons-io</artifactId>
27+
<version>1.3.2</version>
28+
</dependency>
2429
</dependencies>
2530

31+
<build>
32+
<plugins>
33+
<plugin>
34+
<groupId>org.apache.maven.plugins</groupId>
35+
<artifactId>maven-resources-plugin</artifactId>
36+
<version>2.6</version>
37+
<configuration>
38+
<includeEmptyDirs>true</includeEmptyDirs>
39+
</configuration>
40+
</plugin>
41+
</plugins>
42+
</build>
43+
2644
</project>

system-setup/src/main/java/com/thenaglecode/NumericOnlyTextFieldChangeListener.java

-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ public class NumericOnlyTextFieldChangeListener implements ChangeListener<Number
2727
public void changed(ObservableValue<? extends Number> observableValue, Number oldValue, Number newValue) {
2828
if(newValue.intValue() > oldValue.intValue()){
2929
char ch = field.getText().charAt(oldValue.intValue());
30-
System.out.println("Length:" + oldValue +" "+ newValue +" "+ch);
3130

3231
//Check if the new character is the number or other's
3332
if(!(ch >= '0' && ch <= '9')){

system-setup/src/main/java/com/thenaglecode/ServerConfiguration.java

-11
This file was deleted.

system-setup/src/main/java/com/thenaglecode/SettingsFile.java

+12-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.thenaglecode;
22

33
import com.sun.istack.internal.NotNull;
4+
import org.apache.commons.io.IOUtils;
5+
import org.apache.commons.vfs2.FileObject;
46

57
import java.io.*;
68

@@ -26,17 +28,18 @@ public String toString() {
2628
"socket = " + socket;
2729
}
2830

29-
public static SettingsFile fromFile(@NotNull File file) throws IOException {
30-
FileReader in = new FileReader(file);
31-
BufferedReader br = new BufferedReader(in);
32-
String currentLine = br.readLine();
31+
public static SettingsFile fromFile(@NotNull FileObject file) throws IOException {
32+
StringWriter wr = new StringWriter();
33+
IOUtils.copy(file.getContent().getInputStream(), wr, "UTF-8");
34+
String[] lines = wr.toString().split("\n");
35+
3336
SettingsFile settingsFile = new SettingsFile();
34-
while (currentLine != null) {
35-
currentLine = currentLine.trim();
36-
if(currentLine.startsWith("[")){
37-
settingsFile.name = currentLine.substring(1, currentLine.indexOf("]"));
37+
for(String line : lines) {
38+
line = line.trim();
39+
if(line.startsWith("[")){
40+
settingsFile.name = line.substring(1, line.indexOf("]"));
3841
}
39-
String[] split = currentLine.split("=");
42+
String[] split = line.split("=");
4043
if (split.length == 2) {
4144
switch (split[0].trim()) {
4245
case "basedir":
@@ -50,7 +53,6 @@ public static SettingsFile fromFile(@NotNull File file) throws IOException {
5053
break;
5154
}
5255
}
53-
currentLine = br.readLine();
5456
}
5557
return settingsFile.isValid() ? settingsFile : null;
5658
}

0 commit comments

Comments
 (0)