Class JseIoLib

All Implemented Interfaces:
KryoSerializable

public class JseIoLib extends IoLib
Subclass of IoLib and therefore LibFunction which implements the lua standard io library for the JSE platform.

It uses RandomAccessFile to implement seek on files.

Typically, this library is included as part of a call to org.luaj.vm2.lib.jse.JsePlatform#standardGlobals()

 
 Globals globals = JsePlatform.standardGlobals();
 globals.get("io").get("write").call(LuaValue.valueOf("hello, world\n"));
  

For special cases where the smallest possible footprint is desired, a minimal set of libraries could be loaded directly via LuaValue.load(LuaValue) using code such as:

 
 Globals globals = new Globals();
 globals.load(new JseBaseLib());
 globals.load(new PackageLib());
 globals.load(new JseIoLib());
 globals.get("io").get("write").call(LuaValue.valueOf("hello, world\n"));
  

However, other libraries such as MathLib are not loaded in this case.

This has been implemented to match as closely as possible the behavior in the corresponding library in C.

See Also:
  • Constructor Details

    • JseIoLib

      public JseIoLib()