Questions tagged [filereader]

`FileReader` can refer either to the `java.io.FileReader` class for reading files as text in a file system in Java, or to a similar class in JavaScript to access files on a local machine. See the description for more details.

FileReader can refer to two things:

2941 questions
217
votes
10 answers

Do I need to close() both FileReader and BufferedReader?

I'm reading a local file using a BufferedReader wrapped around a FileReader: BufferedReader reader = new BufferedReader(new FileReader(fileName)); // read the file // (error handling snipped) reader.close(); Do I need to close() the FileReader as…
Zilk
  • 8,917
  • 7
  • 36
  • 44
186
votes
17 answers

How to parse Excel (XLS) file in Javascript/HTML5

I am able to read Excel file via FileReader but it outputs text as well as weird characters with it. I need to read xls file row-wise, read data in every column and convert it to JSON. How to read xls file row by row?
ducktyped
  • 4,354
  • 4
  • 26
  • 38
107
votes
8 answers

Difference between java.io.PrintWriter and java.io.BufferedWriter?

Please look through code below: // A.class File file = new File("blah.txt"); FileWriter fileWriter = new FileWriter(file); PrintWriter printWriter = new PrintWriter(fileWriter); // B.class File file = new File("blah.txt"); FileWriter fileWriter =…
i2ijeya
  • 15,952
  • 18
  • 63
  • 72
100
votes
5 answers

What is the difference between Reader and InputStream?

What is the difference between Reader and InputStream? And when to use what? If I can use Reader for reading characters why I will use inputstream, I guess to read objects?
sab
  • 9,767
  • 13
  • 44
  • 51
96
votes
5 answers

GZIPInputStream reading line by line

I have a file in .gz format. The java class for reading this file is GZIPInputStream. However, this class doesn't extend the BufferedReader class of java. As a result, I am not able to read the file line by line. I need something like this reader …
Kapil D
  • 2,662
  • 6
  • 28
  • 30
89
votes
3 answers

fileReader.readAsBinaryString to upload files

Trying to use fileReader.readAsBinaryString to upload a PNG file to the server via AJAX, stripped down code (fileObject is the object containing info on my file); var fileReader = new FileReader(); fileReader.onload = function(e) { var…
Blank
  • 4,635
  • 5
  • 33
  • 53
68
votes
6 answers

Specific difference between bufferedreader and filereader

I would like to know the specific difference between BufferedReader and FileReader. I do know that BufferedReader is much more efficient as opposed to FileReader, but can someone please explain why (specifically and in detail)? Thanks.
Outlier
  • 811
  • 1
  • 7
  • 14
64
votes
8 answers

Read a file synchronously in Javascript

I would like to read a file and convert it into a base64 encoded string using the FileReader object. Here's the code I use : var reader = new FileReader(); reader.onloadend = function(evt) { // file is loaded …
Laila
  • 1,421
  • 3
  • 13
  • 27
57
votes
2 answers

how to read json object in python

I have json file named "panamaleaks50k.json". I want to get ['text'] field from the json file but it shows me following error the JSON object must be str, bytes or bytearray, not 'TextIOWrapper' this is my code with open('C:/Users/bilal…
Bilal Butt
  • 1,202
  • 3
  • 12
  • 15
56
votes
8 answers

Javascript Promises with FileReader()

I have the following HTML Code: And Here's my JS Code: var inputFiles = document.getElementsByTagName("input")[0]; inputFiles.onchange = function(){ var fr = new FileReader(); for(var i = 0; i <…
Zahid Saeed
  • 1,101
  • 1
  • 8
  • 14
54
votes
5 answers

Getting width & height of an image with filereader

I am building an image resize/crop, and I'd like to show a live preview after they've edited it in a modal (bootstrap). This should work, I believe, but I just get 0 in console.log. This requires feeding the width and the height of the original…
Martin Alderson
  • 892
  • 1
  • 7
  • 14
51
votes
2 answers

filereader api on big files

My file reader api code has been working good so far until one day I got a 280MB txt file from one of my client. Page just crashes straight up in Chrome and in Firefox nothing happens. // create new reader object var fileReader = new FileReader();…
ODelibalta
  • 2,194
  • 1
  • 18
  • 28
49
votes
6 answers

Looping through files for FileReader, output always contains last value from loop

I'm using FileReader API to read files on local.