File.stringToByte()

NES2+Syntax

File.stringToByte(string)

Description

The stringToByte() method of the File object is used to convert the first character of the string passed to its binary equivalent.

Example

Listing 8.86 opens two files, one for reading and the other for appending. Strings are then read using the read() method from the first file, converted back to byte characters using the stringToByte() method, and then written to the second file. Both files are closed when the process has completed.

Listing 8.86 Using the stringToByte() Method to Convert the Strings Read into Bytes
 <SERVER> // Open a log file and a summary file var myLog = new File("/data/logs/today.dat"); var mySummary = new File("/data/logs/summary.dat"); // Open ...

Get Pure JavaScript now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.