File operations are very common requirements and I thought of providing some simple examples in Node.js. The Node.js provide a module called "fs" which is having all necessary functions for performing file operations. Let's start with very simple examples. Audience The examples are very basic and focused for beginners. Reading and Writing Files The file system module provide a synchronous and asynchronous functions for reading and writing a file. Example for reading a file using synchronous function fs.readFileSync. const fs = require('fs'); const information = fs.readFileSync('files/file1.txt', 'utf8'); console.log(information); Example for reading a file using asynchronous function fs.readFile. const fs = require('fs'); const information = fs.readFile('files/file1.txt', 'utf8', (err, information) => { if (err) { console.log('Error occured while reading a file'); return; } ...
In my previous blog post , I have explained basics of meteor. In this tutorial I am going to add mobile support to the existing meteor application. Installing mobile SDKs Before going to start we need to install IOS and android SDKs (Software development kit). Here I am installing SDKs for iOS. Please keep in mind this is one time process. For installing iOS SDKs, we need to invoke “meteor install-sdk ios”. The same way you can install android SKDs by invoking “meteor install-sdk android” command. Adding mobile platform support I am using already created application called “myapp” and going to add iOS platform support by invoking a command “ meteor add-platform ios ”. We can add android platform by invoking a command “ meteor add-platform android ”. Running application on mobile emulator Once we add mobile platform then we can run our application by using real mobile device or emulator. I have added IOS platform to myapp already. Now I am going to ru...