This method will close any streams for you, if an exception happens.
See [[zip]] for an example.
Returns a [[Java.IO.ByteArrayOutputStream]]
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.
Input to be parsed.
Optional
charset: stringUse with [[Java.IO.InputStream]] to specify it's charset
[[Text.csv]]
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 |
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:
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))
Returns a [[Java.IO.DataHandler]].
Same as calling dataHandler(dataSource(settings))
Returns a [[Java.IO.DataHandler]].
Returns a [[Java.IO.DataHandler]] from a URL.
Returns a [[Java.IO.DataHandler]] from a URL.
Returns a [[Java.IO.DataSource]].
Returns a [[Java.IO.DataSource]].
Converts a [[Java.IO.InputStream]] to a string.
Optional
charsetname: stringConverts a [[Java.IO.Reader]] to a string.
Transforms [[Java.IO.OutputStream]] to a [[Java.IO.GZIPOutputStream]].
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]].
const unCompressedFileUrl = B.toBinaryFileUrl('secrets.txt', (textFile, out) => {
const gzIn = B.gzip(B.fetch("/temp/secrets.gz"))
gzIn.transferTo(out);
gzIn.close();
});
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.
FetchedResource to read the file
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.
InputStream to read the file.
Optional
fileNameSuffix: stringFile 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.
const pdfDocUrl = B.toBinaryFileUrl(
'myfile.pdf',
(fName, out) => B.pdf(inputStream, '.txt').transferTo(out)),
'application/pdf');
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); }});
B.io.sendMessage({channels: ['chat-7348743'], permissions:['300650_ FID_allStaff'], data: 'Hello World'});
Returns a [[Java.IO.StringReader]] that uses a string for the reader's source
Return a local url to a created temp file using a callback function providing a [[Java.IO.OutputStream]].
Optional
mimetype: string[[B.gzip]]
Converts a [[Java.IO.InputStream]] to an Java.ByteArray
Return url to created temp file using a callback function providing a [[Java.IO.BufferedWriter]].
Optional
mimetype: stringOptional
charSet: string 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]]
Converts a [[Java.ByteArray]] to a [[Java.IO.InputStream]]
Optional
charset: stringProvides a simple JsonWriter Object
Turns a Writer into a PrintWriter.
Converts a [[Java.IO.InputStream]] to a [[Java.IO.BufferedReader]]
Optional
charsetname: stringConverts a [[Java.IO.OutputStream]] to a [[Java.IO.BufferedWriter]]
Optional
charsetname: stringCreates a zip
TODO
Creates a zip
TODO
TODO
TODO
Return [[Java.IO.ZipInputStream]].
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]].
Optional
password: string[]Return [[Java.IO.ZipInputStream]].
Creates [[Java.IO.ZipParameters]] for [[Java.IO.ZipOutputStream]].
[[B.zip]]
Creates [[Java.IO.ZipParameters]] for [[Java.IO.ZipOutputStream]] and setting the fileName. Same as calling B.zipParameters().setFileNameInZip(fileName);
[[B.zip]]
Creates [[Java.IO.ZipParameters]] for [[Java.IO.ZipOutputStream]] copied from zipParams.
[[B.zip]]
Generated using TypeDoc
TODO
Example