Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: assignment help

  1. #1
    New to the CF scene
    Join Date
    Oct 2012
    Thanked 0 Times in 0 Posts

    assignment help

    so does anyone have any idea how to read from a file, for example, called 'abc.txt' then write it to a file called 'def.txt'. im trying to read the prefix tree and im using bitreader/bitwriter and filewriter. thanks. just a brief explanation would do. c:

  2. #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,703 Times in 2,679 Posts
    Are you sure that you are posting in the correct forum, Javascript (not Java)?

    JavaScript running in a browser is a client-side language. JavaScript does not have any commands for reading or writing files. Modern browsers can read files on the server using an Ajax call, but otherwise JavaScript has no capability to read from, write to, modify or delete a file (except a cookie), communicate with the server, access a database, the client's operating system or the Windows registry, or alter the default behaviour of the browser. And for security reasons JavaScript cannot access anything beyond the domain of the current page. This is known as the "same origin policy" and prevents a document or script loaded from one origin from getting or setting properties of a document from a different origin.

    Internet Explorer's JScript (only) lets you write to the Windows local file system by means of the harmless execCommand() function. It is possible in IE in certain circumstances to use ActiveX objects to access the directory and read files. This is not recommended for a variety of reasons.

    All advice is supplied packaged by intellectual weight, and not by volume. Contents may settle slightly in transit.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  3. #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Thanked 4,947 Times in 4,908 Posts
    All those classes mentioned (filewrite, etc.) are indeed JAVA classes.

    This question has nothing to do with JavaScript.
    Be yourself. No one else is as qualified.

  4. #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,668 Times in 2,637 Posts
    Easiest explanation I can think of without code:
    while you read a line from input -> write a line to output.

    Can be done with FileReader and FileWriter objects.

    Also, moving from Javascript to Java forum.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts