Spring Framework FileSystemResource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework FileSystemResource class.

This code example shows how to use the following methods:
 
	protected ExecutionContext executionContext = new ExecutionContext();
 
	protected void setUp(ResourceAwareItemWriterItemStream<String> delegate) throws Exception {
		file = File.createTempFile(MultiResourceItemWriterFlatFileTests.class.getSimpleName(), null);
		tested.setResource(new FileSystemResource(file));
		tested.setDelegate(delegate);
		tested.setResourceSuffixCreator(suffixCreator);
		tested.setItemCountLimitPerResource(2);
		tested.setSaveState(true);
		tested.open(executionContext);
	} 
 
	protected String readFile(File f) throws Exception {
		BufferedReader reader = new BufferedReader(new FileReader(f));
		StringBuilder result = new StringBuilder();
		try { 
			while (true) { 
				String line = reader.readLine();
				if (line == null) {
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 */ 
public class ResourceConverter implements Converter<String, Resource> { 
 
	@Override 
	public Resource convert(String source) { 
		return new FileSystemResource(source + ".xml"); 
	} 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
			assertTrue(e.getMessage().startsWith("Line number 1 does not match."));
		} 
	} 
 
	private void executeAssertEquals(String expected, String actual) throws Exception {
		AssertFile.assertFileEquals(new FileSystemResource(DIRECTORY + expected), new FileSystemResource(DIRECTORY
				+ actual));
	} 
 
	@Test
	public void testAssertLineCount() throws Exception {
		AssertFile.assertLineCount(5, new FileSystemResource(DIRECTORY + "input1.txt"));
	} 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	@Test
	public void testCompareNewWithOld() throws IOException {
		File temp = File.createTempFile(getClass().getSimpleName(), ".txt");
		temp.deleteOnExit();
		assertTrue(temp.exists());
		assertEquals(1, comparator.compare(new FileSystemResource(temp), new FileSystemResource(FILE_PATH)));
	} 
 
	@Test
	public void testCompareNewWithOldAfterCopy() throws Exception {
		File temp1 = new File("build/temp1.txt");
		File temp2 = new File("build/temp2.txt");
		if (temp1.exists()) temp1.delete();
		if (temp2.exists()) temp2.delete();
		temp1.getParentFile().mkdirs();
		temp2.createNewFile();
		assertTrue(!temp1.exists() && temp2.exists());
		// For Linux sleep here otherwise files show same 
		// modified date 
		Thread.sleep(1000);
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	 * Output should be the same as input 
	 */ 
	@Test 
	public void testJob() throws Exception { 
		jobLauncherTestUtils.launchJob(); 
		AssertFile.assertFileEquals(new FileSystemResource(INPUT_FILE), new FileSystemResource(OUTPUT_FILE)); 
	} 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	 * Output should be the same as input 
	 */ 
	@Test 
	public void testJob() throws Exception { 
		jobLauncherTestUtils.launchJob(); 
		AssertFile.assertFileEquals(new FileSystemResource(INPUT_FILE), new FileSystemResource(OUTPUT_FILE)); 
	} 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
	@Override 
	protected Resource getResourceByPath(String path) {
		if (path != null && path.startsWith("/")) {
			path = path.substring(1);
		} 
		return new FileSystemResource(path);
	} 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        visitor.visitCollectorCollection(collector);
        visitor.completeCollectorCollection(collector);
    } 
 
    private CollectdConfiguration getCollectdConfiguration() { 
        return JaxbUtils.unmarshal(CollectdConfiguration.class, new FileSystemResource(m_file));
    } 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    	if(configFile.endsWith(java.io.File.separator)){
    		configFile = configFile.substring(0, configFile.length() - 1);
    	} 
    	configFile += "/etc/QoSD-configuration.xml";
 
		config = CastorUtils.unmarshal(QoSDConfiguration.class, new FileSystemResource(configFile));
		 
		is_loaded = true;
    } 
     
    /** 
     * <p>Getter for the field <code>config</code>.</p> 
     * 
     * @return a {@link org.openoss.opennms.spring.qosd.QoSDConfiguration} object. 
     * @throws java.io.IOException if any. 
     * @throws org.exolab.castor.xml.MarshalException if any. 
     * @throws org.exolab.castor.xml.ValidationException if any. 
     */ 
    public static QoSDConfiguration getConfig() throws IOException,MarshalException,ValidationException{
        if (!is_loaded) {
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        File siteMapFile = siteMapService.getSiteMapFile(getRequestURIWithoutContext(request));
        if (siteMapFile == null || !siteMapFile.exists()) {
            response.setStatus(404);
            return null; 
        } 
        return new FileSystemResource(siteMapFile);
    } 
 
    protected String getRequestURIWithoutContext(HttpServletRequest request) {
        if (request.getContextPath() != null) {
            return request.getRequestURI().substring(request.getContextPath().length());
        } else { 
            return request.getRequestURI();
        } 
    } 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Spring Framework FileSystemResource Methods: