J
Junkone
hello
i am trying to serialise a object to file. i have errors when i try to
restore the object. any ideas
for eg
irb(main):009:0> a=Hash.new
=> {}
irb(main):010:0> a[1]='key'
=> "key"
irb(main):011:0> a[1]='kew'
=> "kew"
irb(main):016:0> a=> {1=>"kew"}
irb(main):022:0> f=File.new("c:\\temp\\log",File::CREAT|File::TRUNC|
File::RDWR)
=> #<File:c:\temp\log>
irb(main):023:0> data=Marshal.dump(a,f)
=> #<File:c:\temp\log>
irb(main):024:0> f.close
=> nil
irb(main):025:0> f1=File.open("c:\\temp\\log",File::NONBLOCK|
File::RDONLY)
=> #<File:c:\temp\log>
irb(main):026:0> Z=Marshal.load(f1)
IOError: not opened for reading from (irb):26:in `getc'
from (irb):26:in `load'
from (irb):26
i am trying to serialise a object to file. i have errors when i try to
restore the object. any ideas
for eg
irb(main):009:0> a=Hash.new
=> {}
irb(main):010:0> a[1]='key'
=> "key"
irb(main):011:0> a[1]='kew'
=> "kew"
irb(main):016:0> a=> {1=>"kew"}
irb(main):022:0> f=File.new("c:\\temp\\log",File::CREAT|File::TRUNC|
File::RDWR)
=> #<File:c:\temp\log>
irb(main):023:0> data=Marshal.dump(a,f)
=> #<File:c:\temp\log>
irb(main):024:0> f.close
=> nil
irb(main):025:0> f1=File.open("c:\\temp\\log",File::NONBLOCK|
File::RDONLY)
=> #<File:c:\temp\log>
irb(main):026:0> Z=Marshal.load(f1)
IOError: not opened for reading from (irb):26:in `getc'
from (irb):26:in `load'
from (irb):26