read and write a file using javascript

read and write a file using javascript

How to read and write a file using javascript?

View Answers

November 9, 2010 at 12:09 PM

Hi,

Here is the answer,

You can read and write a text file using JavaScript as follows

code for reading a file-

<html>
<head>
<script language="javascript">
function Read(){
var Scr  = new ActiveXObject("Scripting.FileSystemObject");
var CTF  = Scr .OpenTextFile("C:\\Gyan.txt", 1, true);
data = CTF .ReadAll(); 
alert(data);
CTF .Close();
}
</script>
</head>
<body onLoad="Read()">
</body>
</html>

For write to a file-

<html>
<head>
<script language="javascript">
function Write()
{
var Scr = new ActiveXObject("Scripting.FileSystemObject");
var CTF = Scr.CreateTextFile("C:\\Gyan.txt", true);
CTF.WriteLine('Roseindia');
CTF.Close();
}
</script>
</head>
<body onLoad="Write()">
</body>
</html>

Thanks,









Related Tutorials/Questions & Answers:
read and write a file using javascript
read and write a file using javascript  How to read and write a file using javascript
simple code to write an read and write the login detail to a xml file using javascript ( username and password )
simple code to write an read and write the login detail to a xml file using javascript ( username and password )  pls can nyone give me a code to write and read the login details (username and password )into a xml file using
Advertisements
how to read and write an xml file using java
how to read and write an xml file using java  Hi Can anyone help me how to read and write an xml file which has CData using java
To read & write a excel file using the core java
To read & write a excel file using the core java  Hai, I'm new to JavaProgram.But now i need java program to read & write a excel file so, can anyone help me to learn the above mentioned topic(link for the portion
write a progam for bubble sort using file read nd write?
write a progam for bubble sort using file read nd write?  hi, please give the code
write a program in java to read a text file and write the output to an excel file using filereader and filewriter?
write a program in java to read a text file and write the output to an excel file using filereader and filewriter?  write a program in java to read a text file and write the output to an excel file using filereader and filewriter
Read and write file
Read and write file  HI, How to read and write file from Java program? Thanks   Hi, See the following tutorials: Java Write To File Read File Thanks
how to read and write xml files in javascript
how to read and write xml files in javascript  hi m very new to javascript and xml,, now i want to read and write xml files in javascript,, please give me a sample code to do
Java file read write operation
Java file read write operation  how to read and write the data from text file.Suppose i have text file with 4 fields name ,roll no ,marks1,marks2 with more than 20 records......i need to store these value in object and pass
JavaScript write to text file
are going to create a file and write text into it using JavaScript. In the given example... JavaScript write to text file  ... a TextStream object to read from or write to the file. The Boolean value defined
read doc and docx file in javascript
read doc and docx file in javascript  How i read doc and docx file in javascript
read/write to Windows Registry using Java
read/write to Windows Registry using Java  read/write to Windows Registry using Java
How to write a search functionality using javascript/jquery
How to write a search functionality using javascript/jquery   How to write a search functionality using javascript/jquery for ex: im searching "s" names it wil display "s" names
How to write to file using FileOutputStream
How to write to file using FileOutputStream  Hi friends, Please help me in java program. How to write to file using FileOutputStream? thanks,   Hi, To write a file using FileOutputStream, we have to use
How to write to file using FileWriter
How to write to file using FileWriter  hi, How to write to file using FileWriter thanks,   Hi, To writing in a file in Java program we... of the FileWriter class can be created using the following of its constructor i.e. FileWriter
Read Text file from Javascript - JSP-Servlet
Read Text file from Javascript  plz send the code How to Retrieve the data from .txt file thru Javascript? And how to find the perticular words in that file
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  ...) { //read from start original file String arry[] = sCurrentLine.split...{ String sCurrentLine; // Groped file name (Suresh.txt
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  ...) { //read from start original file String arry[] = sCurrentLine.split...{ String sCurrentLine; // Groped file name (Suresh.txt
is there any possibelities fast read and write file large data file
is there any possibelities fast read and write file large data file  ...) { //read from start original file String arry[] = sCurrentLine.split...{ String sCurrentLine; // Groped file name (Suresh.txt
Java program to read a text file and write to another file
Java program to read a text file and write to another file - Creating.... Our requirement is to read a text file and then write the content of the text...: In this tutorial we have learned to read a text file and then write it to another file
upload a file and write it in JSP using servlet
upload a file and write it in JSP using servlet  Hello, I'm facing a problem here. I want to upload a file through abc.jsp and write the contents of file using a servlet in xyz.jsp. It is supposed to be a excel file which
Read Write
Read Write  Hi; How can I read certain line of say 10 text files and write to one text file   Java Read Multiple Files and store the data into another text file The given code reads all the text files of the directory
how to read file using InputStreamReader in java
how to read file using InputStreamReader in java  Hi, I want to learn to use the InputStreamReader class of Java and trying to read a text file with the class. how to read file using InputStreamReader in java? Thanks  
read from file and store using hash map
read from file and store using hash map  I was stuck with a java project where I have to read a file with two different concepts and store them differently in hashmap. My data file would be something like Adults: Name, xyz
How to Read a file line by line using BufferedReader?
How to Read a file line by line using BufferedReader?  Hello Java... to Read a file line by line using BufferedReader, efficiently and using less memory... problem is to find the best way to read the file in Java. I just searched the google
read XML file and display it using java servlets
read XML file and display it using java servlets  sir, i can't access Xml which is present in my d drive plz can u should go through my code n tell me the things where i went wrong java servlet program protected void
how to use Excel Templet to write excel file using java.
how to use Excel Templet to write excel file using java.  how to use Excel Templet to write excel file using java
how to use Excel Template to write excel file using java
how to use Excel Template to write excel file using java  How to use Excel template to write data in that file using java
how to write greater than symbol in a file using java
how to write greater than symbol in a file using java  Hello I want to write < and > symbol in a file but its coming like > and < Please... and write the CData from an xml file but not able to print the value of CData
How to read properties file in Python using configparser?
How to read properties file in Python using configparser and printing.... Now we can proceed for developing the program to read properties file using.... Here is the complete code to read properties file in Python using
How to read the data in text file seperated by by ',' in java using IO Operations
How to read the data in text file seperated by by ',' in java using IO Operations  in Text file data like raju 45,56,67 ramu 46,65,78 raji 34,23,56 this is the student marks in text file.this data read and calculate
How to Read file line by line in Java program
Example of Read file line by line using BufferReader: package ReadFile; import.... Example of Read file line by line using Scanner Class: package ReadFile...Programmers have always found it difficult to read a big file (5-10 GB) line
How to Retrieve Data from the database and write into excel file using Java
How to Retrieve Data from the database and write into excel file using Java  Hi, I am trying to develop an small application where i trying to retrieve Data from the database and store the details in excel file. Please can
Java Read .doc file using POI library
Java Read .doc file using POI library In this section, you will learn how to read the word document file using POI library. The class HWPFDocument throw all of the Word file data and the class WordExtractor extract the text from
Read data from excel file and update database using jsp
Read data from excel file and update database using jsp  read data from excel file and update database using jsp Hi, I am using a MySQL database... upload excel file and update database using JSP ? Thanks in Advance
how to read file line by line using filereader in java
how to read file line by line using filereader in java  Hi, how to read file line by line using filereader in java? Thanks   Hi, This is example code: package my.code; import java.io.BufferedReader; import
tow method to read and write .
tow method to read and write .  i have two method , frist named "readString" which has no input ,and output b type string ,. second method named "writeString" which accept b as imput and return nothing .........please i want
read a file
read a file  read a file byte by byte   import java.io.File..._TO_REPLACE_1 public static void main(String[] args) { File file = new File("D://Try.txt"); try { FileInputStream fin = new FileInputStream(file
file read
file read  hi i am reaing from a file which has punjabi words. can some one help with me some code
accessing data from a json file writing javascript or using jQuery
accessing data from a json file writing javascript or using jQuery  I am trying to create a page from json objects using javascript. I have... to javascript using json to create html pages, objects and accessing objects
J2ME RMS Read Write
J2ME RMS Read Write       This Application specially tries to explain how to read and write the data using RecordStore class. In the RecordStore class the following methods
Java Write To File BufferedWriter
); bw.write("This example demonstrates you how to write in a file using...Java Write To File BufferedWriter In this tutorial you will learn how to write to file using BufferedWriter BufferedWriter is a class of java.io package
Java Write To File FileOutputStream
Java Write To File FileOutputStream In this tutorial you will learn how to write to file using FileOutputStream. Write to file using FileOutputStream you... specified by you into which you want to write your contents) and then write to file
Java Write To File FileWriter
str = "This example demonstrates you how to write to file using...Java Write To File FileWriter In this example you will learn how to write to file using FileWriter. Writing to a file there is a class in java.io package
C file write example
C file write example       This section demonstrates you to write the data into the file. Here we are using the library function fwrite() to write the data into the file. You
ModuleNotFoundError: No module named 'write-read'
ModuleNotFoundError: No module named 'write-read'  Hi, My Python... 'write-read' How to remove the ModuleNotFoundError: No module named 'write-read' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'write-read'
ModuleNotFoundError: No module named 'write-read'  Hi, My Python... 'write-read' How to remove the ModuleNotFoundError: No module named 'write-read' error? Thanks   Hi, In your python environment you
how to write and read text for javaME
how to write and read text for javaME  Hi. I have tried ur read/write coding but why i didnt get the o/p just like urs. do i have to add anything from the library? i want to type multiple line on text file then, read it from
Java Write To File From String
Java Write To File From String In this tutorial you will learn how to write to file from string. Write to file from string using java at first we will have to first create a file using the File (in case of the file is not existed
maximize an image using javaScript
maximize an image using javaScript  Write the code to maximize an image using javaScript

Ads