62 lines
1.5 KiB
Java
62 lines
1.5 KiB
Java
package a6;
|
|
|
|
import java.io.File;
|
|
import java.io.FileReader;
|
|
import java.io.BufferedReader;
|
|
import java.io.IOException;
|
|
import java.io.FileNotFoundException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.lang.reflect.Array;
|
|
|
|
public class SysUtils {
|
|
|
|
public static void test() {
|
|
System.out.println("test");
|
|
}
|
|
|
|
public static int getDaySeconds(int time_val, int incdays) {
|
|
int time_zone = 8;
|
|
return (int)((time_val + time_zone * 3600)/3600/24 + incdays) * 3600 * 24 - 3600 * time_zone;
|
|
}
|
|
|
|
public static int now() {
|
|
return (int)(System.currentTimeMillis() / 1000);
|
|
}
|
|
|
|
public static final <T> T[] newArray(Class<T> cls, int size) {
|
|
T[] arr = (T[])Array.newInstance(cls, size);
|
|
try {
|
|
for (int i = 0; i < arr.length; ++i) {
|
|
arr[i] = cls.newInstance();
|
|
}
|
|
return arr;
|
|
} catch (Exception e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public static boolean readStrings(String filename, ArrayList<String> strings) {
|
|
File csvfile = new File(filename);
|
|
csvfile.setReadable(true);
|
|
BufferedReader br = null;
|
|
try {
|
|
br = new BufferedReader(new FileReader(csvfile));
|
|
String line;
|
|
try {
|
|
while ((line = br.readLine()) != null) {
|
|
|
|
}
|
|
br.close();
|
|
} catch (IOException e) {
|
|
return false;
|
|
}
|
|
} catch (FileNotFoundException e) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
}
|