Top "File" questions

A block of arbitrary information, or resource for storing information, accessible by the string-based name or path.

How do I check whether a file exists without exceptions?

How do I check if a file exists or not, without using the try statement?

python file file-exists
How to read a file line-by-line into a list?

How do I read every line of a file in Python and store each line as an element in a …

python string file readlines
How do I include a JavaScript file in another JavaScript file?

Is there something in JavaScript similar to @import in CSS that allows you to include a JavaScript file inside another …

javascript file import include
How do I copy a file in Python?

How do I copy a file in Python? I couldn't find anything under os.

python file copy filesystems file-copying
Writing a list to a file with Python

Is this the cleanest way to write a list to a file, since writelines() doesn't insert newline characters? file.writelines(["%…

python file list file-io newline
How do you append to a file in Python?

How do you append to the file instead of overwriting it? Is there a special function that appends to the …

python file append
Writing files in Node.js

I've been trying to find a way to write to a file when using Node.js, but with no success. …

javascript node.js file express fs
How do I create a Java string from the contents of a file?

I've been using the idiom below for some time now. And it seems to be the most wide-spread, at least …

java string file file-io io
TypeError: a bytes-like object is required, not 'str' when writing to a file in Python3

I've very recently migrated to Py 3.5. This code was working properly in Python 2.7: with open(fname, 'rb') as f: lines = […

python python-3.x string file byte