load a file from classpath spring boot
public void testResourceFile() throws IOException {
File resource = new ClassPathResource("test.json").getFile();
String text = new String(Files.readAllBytes(resource.toPath()));
}
load a file from classpath spring boot
public void testResourceFile() throws IOException {
File resource = new ClassPathResource("test.json").getFile();
String text = new String(Files.readAllBytes(resource.toPath()));
}
load a file from classpath spring boot
private void testResource(Resource resource) {
try {
InputStream resourcee = resource.getInputStream();
String text = null;
try (final Reader reader = new InputStreamReader(resourcee)) {
text = CharStreams.toString(reader);
}
System.out.println(text);
} catch (IOException e) {
e.printStackTrace();
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us