Sha256: f5f5751c225261f9194ded574fe1ddafb4da03cdb42cbc9aa1c8f0da50b3c734

Contents?: true

Size: 784 Bytes

Versions: 6

Compression:

Stored size: 784 Bytes

Contents

# backtick_javascript: true

`/* 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

6 entries across 6 versions & 1 rubygems

Version Path
opal-1.8.3.rc1 stdlib/nashorn/file.rb
opal-1.8.2 stdlib/nashorn/file.rb
opal-1.8.1 stdlib/nashorn/file.rb
opal-1.8.0 stdlib/nashorn/file.rb
opal-1.8.0.beta1 stdlib/nashorn/file.rb
opal-1.8.0.alpha1 stdlib/nashorn/file.rb