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.9 KiB

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