List of usage examples for org.springframework.core.io FileSystemResource FileSystemResource
public FileSystemResource(Path filePath)
From source file:com.home.ln_spring.ch4.XmlConfigWithBeanFactory.java
public static void main(String args[]) { DefaultListableBeanFactory factory = new DefaultListableBeanFactory(); XmlBeanDefinitionReader rdr = new XmlBeanDefinitionReader(factory); rdr.loadBeanDefinitions(new FileSystemResource("src/main/resources/xmlBeanFactory.xml")); Oracle oracle = factory.getBean("oracle", Oracle.class); System.out.println(oracle.defineMeaningOfLife()); }
From source file:net.ab0oo.aprs.clients.JmsBroker.java
public static void main(String[] args) throws Exception { BeanFactory factory = new XmlBeanFactory(new FileSystemResource("web/WEB-INF/classes/broker.xml")); factory.getBean("broker"); System.out.println("JMS Broker starting up"); while (true) { try {//from w w w .j a va2s .c om Thread.sleep(10000); } catch (InterruptedException iex) { } } }
From source file:net.ab0oo.aprs.big.BIG.java
public static void main(String[] args) throws Exception { BeanFactory factory = new XmlBeanFactory(new FileSystemResource("big.xml")); Server server = (Server) factory.getBean("WebServer"); server.start();//from w w w . ja v a2 s. c o m }
From source file:net.ab0oo.aprs.SpringServer.java
public static void main(String[] args) throws Exception { BeanFactory factory = null;//from w w w. j a v a 2 s . co m if (args.length > 0) { factory = new XmlBeanFactory(new FileSystemResource(args[0])); factory.getBean("tcpClient"); } else { factory = new XmlBeanFactory(new FileSystemResource("web/WEB-INF/classes/wedjat.xml")); factory.getBean("tcpClient"); } }
From source file:org.spring.resource.FileSourceExample.java
public static void main(String[] args) { try {/* w w w.ja v a2s . c om*/ String filePath = "E:\\JEELearning\\ideaworlplace\\springdream\\springdream.ioc\\src\\main\\resources\\FileSource.txt"; // ? Resource res1 = new FileSystemResource(filePath); // ? Resource res2 = new ClassPathResource("FileSource.txt"); System.out.println("?:" + res1.getFilename()); System.out.println("?:" + res2.getFilename()); InputStream in1 = res1.getInputStream(); InputStream in2 = res2.getInputStream(); // System.out.println("?:" + read(in1)); // System.out.println("?:" + read(in2)); System.out.println("?:" + new String(FileCopyUtils.copyToByteArray(in1))); System.out.println("?:" + new String(FileCopyUtils.copyToByteArray(in2))); } catch (IOException e) { e.printStackTrace(); } }
From source file:se.uu.it.cs.recsys.dataloader.correction.CourseSelectionRecourseCorrecter.java
public static void main(String[] args) throws IOException { final String COURSE_SEL_REC_FILES_DIR = "file:C:\\Dev\\yong\\CourseRecommenderParent\\CourseRecommenderDataLoader\\src\\main\\resources\\data_source\\course_selection_records"; Resource courseSelectionDir = new FileSystemResource(COURSE_SEL_REC_FILES_DIR); File[] recordFiles = courseSelectionDir.getFile().listFiles(); Arrays.stream(recordFiles).forEach(file -> { try {/* www .j a va 2 s . co m*/ correctCourseName(file, CourseNameCorrectionGenerator.getWrongToCorrectNamePairs()); } catch (IOException ex) { LOGGER.error("Failed to correct names in file.{}", ex); } }); }
From source file:org.transitappliance.loader.LoaderFrontEnd.java
/** * The main CLI of the program. Just loads the config file and spins up Spring. * @param args The command line arguments. Uses varargs so this can be called from a script *//*from w w w.ja v a 2s. co m*/ public static void main(String... args) { // benchmarking long startTime = System.currentTimeMillis(); long totalTime; // Modeled after the main method in OTP Graph Builder // arg checking if (args.length == 0) { System.out.println("usage: loader config.xml"); System.exit(1); } System.out.println("Transit Appliance Stop Loader"); // Load Spring GenericApplicationContext ctx = new GenericApplicationContext(); XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(ctx); // Load config file for this agency and database adapter for (String file : args) reader.loadBeanDefinitions(new FileSystemResource(file)); // get the loader, config'd for this agency TransitStopLoader loader = (TransitStopLoader) ctx.getBean("transitStopLoader"); loader.loadStops(); }
From source file:org.helios.ember.Boot.java
/** * Main boot//from www . j a va2 s. c o m * @param args none */ public static void main(String[] args) { LOG.info("Booting Ember.sftp Server"); try { APPCTX = new GenericXmlApplicationContext( new FileSystemResource("./src/main/resources/META-INF/jetty.xml")); LOG.info("Ember.sftp Server Up"); Thread.currentThread().join(); } catch (Exception ex) { LOG.error("Failed to boot Ember.sftp Server", ex); System.exit(-1); } }
From source file:org.guicerecipes.spring.converter.SpringConverter.java
public static void main(String[] args) { if (args.length == 0) { System.out.println("Usage: springXmlFile [outputDirectory] [outputClassName]"); } else {//ww w . jav a2s .co m String springFile = args[0]; XmlBeanFactory beanFactory = null; try { beanFactory = new XmlBeanFactory(new FileSystemResource(springFile)); } catch (BeansException e) { System.out.println("Failed to open: " + springFile + ". Reason: " + e); e.printStackTrace(); return; } try { SpringConverter converter = new SpringConverter(beanFactory); converter.convert(); } catch (Exception e) { System.out.println("Failed to file from: " + springFile); System.out.println(e); e.printStackTrace(); } } }
From source file:com.yarsquidy.x12.example.exampleSpringParseX12FileOne.java
public static void main(String[] args) { X12 x12 = null;/*from www. j av a 2s .c o m*/ Resource xmlResource = new FileSystemResource("./target/classes/cf/appContext_835_004010X091.xml"); BeanFactory factory = new XmlBeanFactory(xmlResource); Cf cf = (Cf) factory.getBean("bean_X12"); Double totalChargeAmount = 0.0; URL url = exampleSpringParseX12FileOne.class.getClass() .getResource("/org/pb/x12/example/example835One.txt"); File f1 = new File(url.getFile()); Parser parser = new X12Parser(cf); try { x12 = (X12) parser.parse(f1); // calculate the total charge amount List<Loop> loops = x12.findLoop("2100"); for (Loop loop : loops) { for (Segment s : loop) { if (s.getElement(0).equals("CLP")) { totalChargeAmount = totalChargeAmount + Double.parseDouble(s.getElement(3)); } } } System.out.println("Total Charged Amount = " + totalChargeAmount.toString()); // calculate the total charge amount - alternate method totalChargeAmount = 0.0; List<Segment> segments = x12.findSegment("CLP"); for (Segment s : segments) { totalChargeAmount = totalChargeAmount + Double.parseDouble(s.getElement(3)); } System.out.println("Total Charged Amount = " + totalChargeAmount.toString()); } catch (Exception e1) { e1.printStackTrace(); } }