import lombok.SneakyThrows;
public class FileUtilsSneakyThrows {
@SneakyThrows
public static String readFile(File file) {
byte[] bytes = new byte[(int) file.length()];
FileInputStream input = new FileInputStream(file);
input.read(bytes);
return new String(bytes);
}
public static void main(String[] args) {
File file = new File("test.txt");
String content = FileUtilsSneakyThrows.readFile(file);
System.out.println(content);
}
}
Generated:
import java.io.File;
import java.io.FileInputStream;
public class FileUtilsSneakyThrows {
public FileUtilsSneakyThrows() {
}
public static String readFile(File file) {
try {
byte[] bytes = new byte[(int)file.length()];
FileInputStream input = new FileInputStream(file);
input.read(bytes);
return new String(bytes);
} catch (Throwable var3) {
throw var3;
}
}
public static void main(String[] args) {
File file = new File("test.txt");
String content = readFile(file);
System.out.println(content);
}
}
No comments:
Post a Comment