TODO

Example

TODO

Hierarchy

  • IO

Constructors

Methods

  • This method will close any streams for you, if an exception happens.

    Type Parameters

    Parameters

    • ac: T

    Returns T

    Example

    See [[zip]] for an example.
    
  • The csv functions are used to read data in a "comma separated values" format (CSV) or other related format such as tab delimited values. These data formats are used to represent data in rows and columns such as a spread sheet or a single database table. See [[CSV]] for more details.

    Parameters

    • input: InputStream | Reader

      Input to be parsed.

    • Optional charset: string

      Use with [[Java.IO.InputStream]] to specify it's charset

    Returns CSV

    See

    [[Text.csv]]

    Example

    Assume a CSV file exported from a spreadsheet like this one:

    First Last Birthday
    Betsy Ross 01 - Jan - 1735
    Alexander Hamilton 11 - Jan - 1755
    Benjamin Franklin 17 - Jan - 1706
    Daniel Webster 18 - Jan - 1782

    If we assume the CSV document is available on the internet at http://somedomain.com/birthdays.csv and we want to read it and convert it to a list on an html page we could write:
    const fetcher = B.fetch("http://somedomain.com/birthdays.csv");
    const out = "<ul>";
    B.csv(fetcher, fetcher.charset)
    .forEach(row => {
    out += "<li>" + row[0] + " " + row[1] + ": " + row[2] + "</li>";
    });
    out += "</ul>";
    inputStream.close();

    The out variable now contains an HTML snippet that looks like this:

    • First Last: Birthday
    • Betsy Ross: 01 - Jan - 1735
    • Alexander Hamilton: 11 - Jan - 1755
    • Benjamin Franklin: 17 - Jan - 1706
    • Daniel Webster: 18 - Jan - 1782

    A field delimeter and text delimeter can also be specifed for other types of files. For example a tab delimeted file:

    B.csv(tsvText)
    .fieldDelimeter('\n') //default but specified here as an example
    .textDelimeter('\t');
    .forEach(row => {
    //process row
    });
  • Returns a [[Java.IO.DataHandler]]. Same as calling dataHandler(dataSource(name, contentType, inputStream, outputStream))

    Parameters

    Returns DataHandler

  • Returns a [[Java.IO.DataHandler]]. Same as calling dataHandler(dataSource(settings))

    Parameters

    Returns DataHandler

  • Returns a [[Java.IO.DataHandler]].

    Parameters

    • obj: any
    • mimeType: string

    Returns DataHandler

  • Returns a [[Java.IO.DataHandler]] from a URL.

    Parameters

    Returns DataHandler

  • Returns a [[Java.IO.DataHandler]] from a URL.

    Parameters

    • url: string

    Returns DataHandler

  • Returns this scripts draft folder.

    Returns Folder

  • Converts a [[Java.IO.InputStream]] to a string.

    Parameters

    Returns string

  • Converts a [[Java.IO.Reader]] to a string.

    Parameters

    Returns string

  • Returns the Stack Trace as a string if e is a java exception. Else, returns e.toString().

    Parameters

    • e: any

    Returns string

  • Returns the Stack Trace as a string if e is a java exception. Else, returns e.

    Parameters

    • e: any

    Returns any

  • Transforms [[Java.IO.OutputStream]] to a [[Java.IO.GZIPOutputStream]].

    Parameters

    Returns GZIPOutputStream

    Example

        const url = B.toBinaryFileUrl("zip.gz", (gzfile, out) => {
    const zipOut = B.gzip(out)
    const writer = B.toWriter(zipOut);
    writer.append("Hello world");
    writer.append("End.");
    writer.close();
    });
  • Transforms [[Java.IO.Inputstream]] to a [[Java.IO.GZIPInputStream]].

    Parameters

    Returns GZIPInputStream

    Example

      const unCompressedFileUrl = B.toBinaryFileUrl('secrets.txt', (textFile, out) => {
    const gzIn = B.gzip(B.fetch("/temp/secrets.gz"))
    gzIn.transferTo(out);
    gzIn.close();
    });
  • This method provides a callback function that provides an [[IO]] object.

    Type Parameters

    • T

    Parameters

    • ioConsumer: ((io) => T)

    Returns T

    Example

    See [[zip]] for an example.
    
  • Returns a JSch object

    Parameters

    • host: string

    Returns JSch

  • Retrieves a PDF document given the [[Bluestep.Net.FetchedResource]]. If the retrieved resource is not a PDF then it will try to convert it to a PDF. The resulting PDF object can be used to inspect and modify the PDF. Currently only form field values within the PDF can be inspected and modified.

    Parameters

    Returns PDFDocument

    Example

    const pdfDocUrl = B.toBinaryFileUrl(
    'myfile.pdf',
    (fName, out) => B.pdf(B.fetch('/home.html').transferTo(out)),
    'application/pdf');
  • Retrieves a PDF document given the [[Java.IO.InputStream]]. If a file suffix is provided, it will try to convert the [[Java.IO.InputStream]] to a PDF. The resulting [[PDFDocument]] can be used to inspect and modify the PDF. Currently only form field values within the PDF can be inspected and modified.

    Parameters

    • input: InputStream

      InputStream to read the file.

    • Optional fileNameSuffix: string

      File suffix of the [[Java.IO.InputStream]]. Used to help in conversion to pdf. If not provided then the [[Java.IO.InputStream]] is assumed to be a pdf.

    Returns PDFDocument

    Example

    const pdfDocUrl = B.toBinaryFileUrl(
    'myfile.pdf',
    (fName, out) => B.pdf(inputStream, '.txt').transferTo(out)),
    'application/pdf');
  • Calls console.error(e). If e is a Java.Throwable, then it will generate a stack trace.

    Parameters

    • e: any

    Returns void

  • Returns this script's draft root folder if debugging otherwise returns snapshot's root folder.

    Returns Folder

  • Sends a message. This will send data to the channels and permissions specified in the message object.Javascript on the page can listen to the following example message by using: bsmsg.listen({channels: ['chat-7348743'], onMessage: msg => { console.log("msg=",msg); }});

    Parameters

    Returns void

    Example

    B.io.sendMessage({channels: ['chat-7348743'], permissions:['300650_ FID_allStaff'], data: 'Hello World'});
    
  • Returns this scripts snapshot folder.

    Returns Folder

  • Returns a [[Java.IO.StringReader]] that uses a string for the reader's source

    Parameters

    • input: string

    Returns StringReader

  • Returns a [[Java.IO.StringWriter]] that streams to a string

    Returns Writer

  • Return a local url to a created temp file using a callback function providing a [[Java.IO.OutputStream]].

    Parameters

    • filename: string
    • writerConsumer: ((filename, gzOut) => void)
        • (filename, gzOut): void
        • Parameters

          Returns void

    • Optional mimetype: string

    Returns void

    Example

    [[B.gzip]]
    
  • Converts a [[Java.IO.InputStream]] to an Java.ByteArray

    Parameters

    Returns ByteArray

  • Return url to created temp file using a callback function providing a [[Java.IO.BufferedWriter]].

    Parameters

    • filename: string
    • writerConsumer: ((filename, gzOut) => void)
        • (filename, gzOut): void
        • Parameters

          Returns void

    • Optional mimetype: string
    • Optional charSet: string

    Returns string

    Example

        const url = B.toFileUrl(
    "text.text",
    (filename, writer) => {
    writer.append("Hello world");
    writer.append("End.");
    }, "text/plain",
    "UTF-8");
  • Converts a [[Java.ByteArray]] to a [[Java.IO.InputStream]]

    Parameters

    Returns InputStream

  • Converts a [[Java.ByteArray]] to a [[Java.IO.InputStream]]

    Parameters

    • input: string
    • Optional charset: string

    Returns InputStream

  • Provides a simple JsonWriter Object

    Parameters

    Returns JsonWriter

  • Converts a [[Java.IO.InputStream]] to a [[Java.IO.BufferedReader]]

    Parameters

    Returns BufferedReader

  • Converts a [[Java.IO.OutputStream]] to a [[Java.IO.BufferedWriter]]

    Parameters

    Returns BufferedWriter

  • Creates a zip

    Parameters

    • out: OutputStream
    • charset: string
    • password: string[]
    • fnc: ((zipOutputStreamData) => void)

    Returns void

    Example

    TODO
    
  • Creates a zip

    Parameters

    • out: OutputStream
    • password: string[]
    • fnc: ((zipOutputStreamData) => void)

    Returns void

    Example

    TODO
    
  • TODO

    Parameters

    • out: OutputStream
    • charset: string
    • fnc: ((zipOutputStreamData) => void)

    Returns void

  • TODO

    Parameters

    Returns void

  • Return [[Java.IO.ZipInputStream]].

    Parameters

    Returns ZipInputStream

    Example

    const urls = [];
    const zipIn = B.zip(B.fetch("/temp/kjdfklj/test.zip"));
    const entry;
    while ((entry = zipIn.getNextEntry()) != null) {
    const url = B.toBinaryFileUrl(entry.getName(), (fName, out) => {
    zipIn.transferTo(out);
    });
    urls.push(url);
    }
  • Return [[Java.IO.ZipInputStream]].

    Parameters

    Returns ZipInputStream

  • Return [[Java.IO.ZipInputStream]].

    Parameters

    Returns ZipInputStream

  • Creates [[Java.IO.ZipParameters]] for [[Java.IO.ZipOutputStream]].

    Returns ZipParameters

    See

    [[B.zip]]

  • Creates [[Java.IO.ZipParameters]] for [[Java.IO.ZipOutputStream]] and setting the fileName. Same as calling B.zipParameters().setFileNameInZip(fileName);

    Parameters

    • fileName: string

    Returns ZipParameters

    See

    [[B.zip]]

  • Creates [[Java.IO.ZipParameters]] for [[Java.IO.ZipOutputStream]] copied from zipParams.

    Parameters

    Returns ZipParameters

    See

    [[B.zip]]

Generated using TypeDoc