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

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