use of dyvil.annotation.internal.DyvilModifiers in project Dyvil by Dyvil.
the class FileUtils method create.
@DyvilModifiers(Modifiers.INFIX)
public static void create(@NonNull File file) throws IOException {
if (file.exists()) {
return;
}
final File parent = file.getParentFile();
if (parent != null && !parent.exists() && !parent.mkdirs()) {
throw new IOException("Could not create parent directory: " + parent);
}
// noinspection ResultOfMethodCallIgnored
file.createNewFile();
}
use of dyvil.annotation.internal.DyvilModifiers in project Dyvil by Dyvil.
the class FileUtils method readLines.
@DyvilModifiers(Modifiers.INFIX)
@NonNull
public static List<@NonNull String> readLines(@NonNull File file) throws IOException {
try (BufferedReader reader = Files.newBufferedReader(file.toPath())) {
final List<String> result = new ArrayList<>();
for (; ; ) {
String line = reader.readLine();
if (line == null) {
break;
}
result.add(line);
}
return result;
}
}
use of dyvil.annotation.internal.DyvilModifiers in project Dyvil by Dyvil.
the class ObjectReflection method copyFields.
@DyvilModifiers(Modifiers.INFIX)
public static <T> void copyFields(@NonNull T from, T to) {
try {
Class<?> c = from.getClass();
do {
for (Field f : c.getDeclaredFields()) {
if ((f.getModifiers() & Modifiers.STATIC) == 0) {
f.setAccessible(true);
f.set(to, f.get(from));
}
}
c = c.getSuperclass();
} while (c != null);
} catch (Exception ex) {
ex.printStackTrace();
}
}
Aggregations