You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

loadfile.html 2.6 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <html>
  2. <head>
  3. <title>LoadFile Task</title>
  4. </head>
  5. <body>
  6. <h2><a name="loadfile">LoadFile</a></h2>
  7. <h3>Description</h3>
  8. <p>
  9. Load a text file into a single property. Unless an encoding is specified,
  10. the encoding of the current locale is used.
  11. </p>
  12. <h3>Parameters</h3>
  13. <table border="1" cellpadding="2" cellspacing="0">
  14. <tr>
  15. <td valign="top"><b>Attribute</b></td>
  16. <td valign="top"><b>Description</b></td>
  17. <td align="center" valign="top"><b>Required</b></td>
  18. </tr>
  19. <tr>
  20. <td valign="top">srcFile</td>
  21. <td valign="top">source file</td>
  22. <td valign="top" align="center">Yes</td>
  23. </tr>
  24. <tr>
  25. <td valign="top">property</td>
  26. <td valign="top">property to save to</td>
  27. <td valign="top" align="center">Yes</td>
  28. </tr>
  29. <tr>
  30. <td valign="top">encoding</td>
  31. <td valign="top">encoding to use when loading the file</td>
  32. <td align="center" valign="top">No</td>
  33. </tr>
  34. <tr>
  35. <td valign="top">failonerror</td>
  36. <td valign="top">Whether to halt the build on failure</td>
  37. <td align="center" valign="top">No, default "true"</td>
  38. </tr>
  39. </table>
  40. <p>
  41. The LoadFile task supports nested <a href="../CoreTypes/filterchain.html">
  42. FilterChain</a>s.
  43. <h3>Examples</h3>
  44. <pre> &lt;loadfile property="message"
  45. srcFile="message.txt"/&gt;
  46. </pre>
  47. Load file message.txt into property "message"; an <tt>&lt;echo&gt;</tt>
  48. can print this.
  49. <pre> &lt;loadfile property="encoded-file"
  50. srcFile="loadfile.xml"
  51. encoding="ISO-8859-1"/&gt;
  52. </pre>
  53. Load a file using the latin-1 encoding
  54. <pre> &lt;loadfile
  55. property="optional.value"
  56. srcFile="optional.txt"
  57. failonerror="false"/&gt;
  58. </pre>
  59. Load a file, don't fail if it is missing (a message is printed, though)
  60. <pre> &lt;loadfile
  61. property="mail.recipients"
  62. srcFile="recipientlist.txt"&gt;
  63. &lt;filterchain&gt;
  64. &lt;<a href="../CoreTypes/filterchain.html#striplinebreaks">striplinebreaks</a>/&gt;
  65. &lt;/filterchain&gt;
  66. &lt;/loadfile&gt;
  67. </pre>
  68. Load a property which can be used as a parameter for another task (in this case mail),
  69. merging lines to ensure this happens.
  70. <pre> &lt;loadfile
  71. property="system.configuration.xml"
  72. srcFile="configuration.xml"&gt;
  73. &lt;filterchain&gt;
  74. &lt;<a href="../CoreTypes/filterchain.html#expandproperties">expandproperties</a>/&gt;
  75. &lt;/filterchain&gt;
  76. &lt;/loadfile&gt;
  77. </pre>
  78. Load an XML file into a property, expanding all properties declared
  79. in the file in the process.
  80. <hr>
  81. <p align="center">Copyright &copy; 2001-2002,2004 The Apache Software Foundation. All rights
  82. Reserved.</p>
  83. </body>
  84. </html>