Sha256: 5ca1a995acaffb77c212274771717c5f29abab7367c083e473525cbda65ffd30

Contents?: true

Size: 755 Bytes

Versions: 20

Compression:

Stored size: 755 Bytes

Contents

`/* global Java */`

require 'corelib/file'

class File
  def self.read(path)
    %x(
        var Paths = Java.type('java.nio.file.Paths');
        var Files = Java.type('java.nio.file.Files');
        var lines = Files.readAllLines(Paths.get(path), Java.type('java.nio.charset.StandardCharsets').UTF_8);
        var data = [];
        lines.forEach(function(line) { data.push(line); });
        return data.join("\n");
      )
  end

  def self.file?(path)
    %x{
      var Files = Java.type('java.nio.file.Files');
      return Files.exists(path) && Files.isRegularFile(path);
    }
  end

  def self.readable?(path)
    %x{
      var Files = Java.type('java.nio.file.Files');
      return Files.exists(path) && Files.isReadable(path);
    }
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
opal-1.7.4 stdlib/nashorn/file.rb
opal-1.7.3 stdlib/nashorn/file.rb
opal-1.7.2 stdlib/nashorn/file.rb
opal-1.7.1 stdlib/nashorn/file.rb
opal-1.7.0 stdlib/nashorn/file.rb
opal-1.7.0.rc1 stdlib/nashorn/file.rb
opal-1.6.1 stdlib/nashorn/file.rb
opal-1.6.0 stdlib/nashorn/file.rb
opal-1.6.0.rc1 stdlib/nashorn/file.rb
opal-1.6.0.alpha1 stdlib/nashorn/file.rb
opal-1.5.1 stdlib/nashorn/file.rb
opal-1.5.0 stdlib/nashorn/file.rb
opal-1.5.0.rc1 stdlib/nashorn/file.rb
opal-1.4.1 stdlib/nashorn/file.rb
opal-1.4.0 stdlib/nashorn/file.rb
opal-1.4.0.alpha1 stdlib/nashorn/file.rb
opal-1.3.2 stdlib/nashorn/file.rb
opal-1.3.1 stdlib/nashorn/file.rb
opal-1.3.0 stdlib/nashorn/file.rb
opal-1.3.0.rc1 stdlib/nashorn/file.rb