ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rebhan, Gilbert" <Gilbert.Reb...@huk-coburg.de>
Subject RE: Open and read file with ant and then copy
Date Mon, 10 Sep 2007 12:44:03 GMT
 

Hi,

-----Original Message-----
From: Rebhan, Gilbert [mailto:Gilbert.Rebhan@huk-coburg.de] 
Sent: Monday, September 10, 2007 12:49 PM
To: Ant Users List
Subject: RE: Open and read file with ant and then copy

Oops, use =

<script language="ruby">
<![CDATA[
     
require 'fileutils'
File.open('C:\WKS\Eclipse322\WEB_neu\copytest.txt', "r").each do |line|
  arr=line.split(' ')
  FileUtils.mkdir_p(File.dirname(arr[1]),:verbose=>true)
  FileUtils.cp(arr[0],arr[1],:verbose=>true)
end
]]>
</script>

instead of =
      
require 'fileutils'
     
File.open('C:\WKS\Eclipse322\test\copytest.txt', "r").each do |line|
  FileUtils.mkdir_p(File.dirname(line.split(' ')[1]),:verbose=>true)
  FileUtils.cp(line.split(' ')[0],line.split(' ')[1],:verbose=>true)
end

so the method line.split() is only called once
If you need another separator, i.e.  # just use line.split('#')

Regards, Gilbert

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message