See: Description
Interface | Description |
---|---|
MacroConverter |
Class | Description |
---|---|
FileMacroConverter |
FileMacroConverter - converts macros a file at a time.
|
StringMacroConverter |
StringMacroConverter - converts macros in a String.
|
Package Specification.
The macro classes consist of two converters.
Related Documentation
Example Usages:
String usage:
public void StringTest3() { StringMacroConverter filter = StringMacroConverter.getConverter(MacroConverter.MAKE_CONVERTER); String orig = "Your OS is $(os.name), running on an $(os.arch) cpu."; String news = filter.expandString(orig, System.getProperties()); System.out.println(news); }
File usage:
public void FileTest1() throws Exception { FileMacroConverter filter = FileMacroConverter.getConverter(MacroConverter.AT_CONVERTER); File sourceFile = new File("C:\\src.txt"); String text = "Your OS is @os.name@, running on an @os.arch@ cpu."; createTempFile(sourceFile, text); File destFile = new File("C:\\dest.txt"); if (destFile.exists()) { destFile.delete(); } filter.expandFile(sourceFile, destFile, System.getProperties()); } private void createTempFile(File sourceFile, String text) throws Exception { if (sourceFile.exists()) { sourceFile.delete(); } sourceFile.createNewFile(); FileOutputStream fos = new FileOutputStream(sourceFile); fos.write(text.getBytes()); fos.close(); }