load a file from classpath spring boot

Solutions on MaxInterview for load a file from classpath spring boot by the best coders in the world

showing results for - "load a file from classpath spring boot"
Lennart
09 Aug 2018
1	public void testResourceFile() throws IOException {
2		File resource = new ClassPathResource("test.json").getFile();
3		String text = new String(Files.readAllBytes(resource.toPath()));
4	}
5
Oli
01 Nov 2016
1    private void testResource(Resource resource) {
2		try {
3			InputStream resourcee = resource.getInputStream();
4			String text = null;
5			try (final Reader reader = new InputStreamReader(resourcee)) {
6				text = CharStreams.toString(reader);
7			}
8			System.out.println(text);
9 
10		} catch (IOException e) {
11			e.printStackTrace();
12		}
13	}
14
queries leading to this page
how to load resource file in spring bootspring read file on pathfile from resource java springspring boot load file from resourcesaccess xmlfile under resources springbootspring get file by pathhow to use classpath in spring bootread file java spring boothow to get resources as stream from claaspath in spring bootspring boot jar read file from classpathhow to pick file path in java springspring boot get inputstream of an filespring readfile from respurcescreate a file in classpath in springbootmicroservices using file spring boot read file from resourceshow to get resource folder path in spring bootapplication xml file is in resources folder in spring boot appspring boot resource folder in classpathjava spring read text filehow to specify file path in spring bootspring boot create a class with filespring boot resource file read writeread file in spring boot applicationspring boot access resource fileload a file from classpath spring boot spring resource from file or classpathspring classpath file access to return htmlspring boot get resource folder pathread file from resources spring bootfile path in spring bootload file from classpath spring bootspring application get resources filespring read file from class pathread file from disk springspring load file from resourcesread classpath resource in spring bootreading sream from resourcces in spring boothow to load the document in spring bootload file from resources in spring bootjava spring boot read text fileget file from classpath spring bootspring boot load file from resources directoryget fileinputstream from spring resourcereading resource folder in jar springspring boot get file from resourcesaccess resource file spring bootspring boot get resource from filejava read file from resources spring bootread image from resource folder spring bootread file in spring bootspring map a resource file classpathread file from classpath spring bootspring boot read file from pathspring accessing file in resourcesclasspathresource to readerspring read file from resourcesread file from resources in controller sprin bootloading external file in classpath springclasspath resource to fileget file from resources springread file spring bootspring load json file from classpathspring load file from classpathspring boot read resource filespring boot load file from classpathread file content to string classpath spring bootspring resource resource fileget resource file spring bootspring boot load from classpathclasspath spring bootspring boot read filenew file get resource springclasspath in java spring bootget file from resources java spring bootget all file classpathresource spring bootspring find files in classpathresource get file springhow to read file path in spring boot using 40valueexternal file classpath spring boot propertieshow to load a file in spring bootget file path springspring boot read json file from resources folderspring boot load file from ressourcesresource spring bootspring classpath resource readerspring boot content read file content from filesystemmaven spring read file from classpathspring boot file read exampleresourceloader spring bootget resource path in spring boothow to access resources folder in spring boot load a file from classpath spring boot