FAQ Database Discussion Community


how to read and load a file with these characters in java?

java,netbeans,filereader
I have for example a file and within empleados.txt has this information " x002 ; Peter ; Tor ; 1200.0 ; 1992/4/4 " without quotes Only I get to read the file when the file is inside " ; " if I have "/" I get no reading thx public...

Trying to read a data.txt file and do calculations

java,bufferedreader,filereader
I am using Integer.parseInt() to change the String variables of each line of data.txt to an int data type. The data.txt file looks like this: 5 6 3 5 0 ...and so on. I also have no spaces in the text file so I should be able to parse the...

Polyfill for FileReader API

javascript,flash,internet-explorer-9,filereader
Please help me out on using fileReader polyfill for IE9. Im unable to get it out on how to use it Please correct me if im doing anything wrong here. Im trying to use the FileReader API Shim for IE9. But on change event of the input type = file,...

Javascript FileReader: Extracting text

javascript,scope,filereader
I'm having trouble preserving data extracted from a file read in by FileReader. In the scope of the onload function the data seems to exist, but trying to store said data in a variable outside the scope does not seem to work. MWE: http://jsfiddle.net/eqaw0hbf/1/ (Upload any text file and you'll...

java filereader read at offset

java,offset,filereader
How do I use FileReader.read() to read a byte at a specific offset? FileReader fr = new FileReader(path); char[] tmp = null; fr.read(tmp, 11, 1); n = tmp.toString(); n = Integer.parseInt(n,16); This code returns nullpointerexception although the file in 'path' is valid and not empty. What I intend to do...

I use JavaScript FIleReader read a pic , but I can't get the pic 's infomation .

javascript,image,filereader
I can't get the picture's infomation use code below . I don't know why . var f = obj.files[0]; var imageType = /image.*/; if (f.type.match(imageType)) { var r = new FileReader(); r.onload = function(e) { var value = r.result; var img = new Image(); img.src = value; alert(img.width+" "+img.height); }...

JavaScript readAsDataurl is not a function

javascript,filereader
In Gecko/Firefox I got the error message: TypeError: fr.readAsDataurl is not a function Using the following JavaScript: var fr = new FileReader(); fr.readAsDataURL(files[i]); ...

store double variable values in to list [closed]

java,file,csv,filereader,opencsv
I am working with csv file having very large dataset. while reading file i had extracted 3rd place(BALANCE) ';' separated numeric value from each rows with in while loop iteration.i want to store those values(BALANCE) into listOF string.how can i do this. import java.io.File; import java.io.FileNotFoundException; import java.io.*; public static...

How do I filter results in .txt file

java,filereader
I am trying to read data inside a .txt file but I am getting following errors: java.io.FileNotFoundException: test.txt (No such file or directory) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:138) at java.util.Scanner.<init>(Scanner.java:611) at javaapplication3.JavaApplication3.main(JavaApplication3.java:32) This is my code: public static void main(String[] args) { String userHomeFolder = System.getProperty("/Users/computername/Desktop"); File file = new...

Download Excel file from server and save on client

javascript,excel,blob,filereader
I have a JavaScript app and an API that creates a Excel file and returns a byte array with the following headers: Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet Content-Disposition:attachment; filename=List.xlsx When I go the Excel resource API URL I'm prompted to download the Excel file. If I do so, it downloads fine and opens...

Java - Writing and Reading ArrayList to and from .txt file - BufferedWriter

java,bufferedreader,filereader,filewriter,bufferedwriter
Some Background: I'm making an RPG text based game for class, and I'm using an ArrayList for the inventory, since of course, it will constantly be changing whenever another item is added. I want to be able to save this ArrayList into a txt file and I want to be...

Zipping and uploading files using PhoneGap and JSZip

cordova,promise,filereader,jszip,ramda.js
I've got code that reads a local folder, then zips up relevant files and uploads them to a server: var dirEntry = fileSystem.createReader(); dirEntry.readEntries( function (entries) { if (entries.length === 0) return; var options = new FileUploadOptions(); /* Details omitted */ var zip = new JSZip(); // Map function from...

Java FileReader: How to assign every line in the text file to a variable

java,file,filereader
I want every line in my textdoc to be assigned to a variable. import java.io.*; import static java.lang.System.*; class readfile { public static void main(String[] args) { try { FileReader fr = new FileReader("filename"); BufferedReader br = new Buffered(fr); String str; while ((str = br.readLine()) != null) {} br.close(); }...

Chrome App FileReader

google-chrome-app,filereader
I'm trying to make use of the file system API in a Chrome App. I've tried all the sample code I can find and can't get a simple text file to read. I'm logging almost every step, and what seems to happen (or not happen) is everything stops the first...

ng-repeat not processing upon FileReader

javascript,angularjs,filereader
So this is how my view looks: <body ng-controller="AdminCtrl"> <img ng-repeat="pic in pics" ng-src="{{pic}}" /> <form ng-submit="postPic()"> <input id="photos" type="file" accept="image/*" multiple/> <button>Add Pics</button> </form> And this is the controller: app.controller('AdminCtrl',['$scope', function($scope){ $scope.pics =[]; $scope.postPic = function() { var files = $('#photos').get(0).files; for (var i = 0, numFiles = files.length;...

Working with promises jQuery

javascript,jquery,arrays,promise,filereader
I have to store some images, I'm taking the value like this: var imgGaleria1 = $("#imgGaleria1")[0].files[0]; var imgGaleria1Blob; if (imgGaleria1) { var reader = new FileReader(); reader.onload = function (e) { reader.readAsDataURL(imgGaleria1); imgGaleria1Blob = e.target.result; }; } But obviously I can't store into imgGaleria1Blob, because reader is just async task,...

Java: BufferedReader Keeps Writing Values 128-159 as 63 When Converting to Char

java,bufferedreader,filereader,filewriter,bufferedwriter
I am trying to write a hex editor. I'm trying to store values by writing a char to a text file. For some reason every decimal number 128-159 is being written or read (not sure which) as 63. I took measures to isolate the problem. Here's an example of it...

HTML5 file upload script not loading file

javascript,html5,filereader
Newbie to the HTML5 file upload capability, and finding I cant get a simple xml file uploaded and able to get file contents into console. The expected behaviour is that I'd select an xml file and then see the contents rendered in console. However, I dont ever get to the...

Reading .ini File When Converted into Runnable Jar File

java,bufferedreader,filereader,ini,ini4j
I have a project which I am going to convert it into runnable jar file. I am storing some of the configurations in my ini file with using ini4j. It works when I simply set the directory getConf = new Ini(new FileReader(path));, but it wont work when I use getResourceAsStream()...

How do I delete words containing a certain charater in java?

java,regex,string,filereader,symbols
Is there a way to delete a whole word that contains the "@" character using regular expressions? For example, the following words should be removed: kʌ[email protected]ənɪu and [email protected] I have tried: line = br.readLine(); line = line.replaceAll("\\b[@]+\\b",""); System.out.println(line); ... which only deletes the "@" symbol, not the word itself....

Java reading a string from a text(txt) file

java,string,bufferedreader,filereader
Rod Rae Bryan Shiroe Ric Kirito Asuna Elsa Akutabe Shino I have that list saved in a text file. If I were to enter Rod, it should say "Exists" and if I enter a name that is not on the list, it should say "Does not exist." But what...

How to browse local files from Django and store the file information

javascript,jquery,django,file-upload,filereader
I'm new to Django and want to give a user the ability to browse through their local files and "upload" them. However I do not actually want to store their files on my database, I only want to get the filename, path, memory etc of the file the user has...

Python: Fastest way to process large file

python,file,python-2.7,filereader
I have multiple 3GB tab delimited files. There are 20 million rows in each file. All the rows have to be independently processed, no relation between any two rows. My question is, what will be faster A. Reading line by line using ` with open() as infile: for line in...

filereader result order changing while uploading multiple images in javascript

javascript,jquery,javascript-events,filereader
I am trying to upload multiple images and place in separate img tag using javascript.Here is what i tried, MyJsp.jsp : <div> <img alt="Image1" id="Image1" src="" width="130px" height="90px"><br><br> <img alt="Image2" id="Image2" src="" width="130px" height="90px"><br><br> <img alt="Image3" id="Image3" src="" width="130px" height="90px"><br><br> <img alt="Image4" id="Image4" src="" width="130px" height="90px"><br><br> <img alt="Image5" id="Image5" src=""...

How can I read a text file, search for commas, treat commas as new lines, and export it to a new file using Java?

java,text,bufferedreader,filereader
I have a .txt file with 1 billion items separated by commas. I want to be able to read the file.txt file, allow my script to read the commas, copy the item before the comma into a new file, and start a new line after every comma. Example of the...

Loading binary image data to an image fails on Android 4.1 in Cordova Project

android,cordova,sencha-touch,blob,filereader
I have serious issues loading binary image data into a simple image-element. I coded a cordova app (using Sencha touch) which loads images the following way: xhr.open('GET', imageUrl, true); xhr.responseType = 'blob'; xhr.addEventListener('load', function () { if (xhr.status === 200) { // onload needed since Google Chrome doesn't support addEventListener...

FileReader on safari firing to soon

javascript,canvas,safari,filereader
I'm working on a multi part html questionnaire style form that has a lot of text questions along with a few images. On questions that are images the user is selects the image, i create a canvas element and display the resized image in it underneath the file input. if...

How to open a local file with Javascript FileReader()

javascript,filereader,local-files
I would like to modify this code so that it works with a specific file only, but I can't figure out the correct URL parameter and all the code examples that I've found use a file selection dialog. <!DOCTYPE html> <html> <head> <title>reading file</title> <script type="text/javascript"> var reader = new...

Loading CSV with FileReader to make JS Objects for Map Markers (Maps API)

javascript,google-maps,csv,google-maps-api-3,filereader
Basically I'm trying to load a csv file, parse it to an array of js objects and use those objects to make map markers with the Google Maps API. The loading works, the parsing works, all the values are correct (to my knowledge), I've been console logging to death and...

File reading in html

javascript,html,html5,filereader
I want to know if there are any methods other than file reading api and XMLHttprequest() to read/load text files which support almost all the web browsers. I'm not using xmlhttprequest() since it cannot be run in few browsers, like chrome(since it has a bug) you may find it here...

Should BufferedReaders be passed a dynamic FileReader?

java,performance,bufferedreader,filereader,java-io
As the question states, is passing a dynamic FileReader bad practice? Should this/can this FileReader be closed sufficiently? BufferedReader buffReader = new BufferedReader( new FileReader(new File("C:/Path/To/File.txt"))); .... do something buffReader.close(); Should the FileReader also be closed? Would separation be required to do so? Perhaps a simple question, but I'm not...

Read FileReader object line-by-line without loading the whole file into RAM

javascript,html5,filereader
Now that many browsers support reading local files with HTML5's FileReader, this opens the door to websites which go beyond 'database front-ends' into scripts which can do something useful with local data without having to send it up to a server first. Pre-processing images and video before upload aside, one...

java hadoop: FileReader VS InputStreamReader

java,hadoop,bufferedreader,filereader,inputstreamreader
i want use my java class on the hadoop hdfs, now i must rewrite my functions. the problem is, if i use the InputStreamReader my app read wrong values. here my code (so it's work, i want use the uncommented code part): public static GeoTimeDataCenter[] readCentersArrayFromFile(int iteration) { Properties pro...

JS FileReader: Read CSV from Local File & jquery-csv

javascript,csv,filereader
I have a CSV file in the same directory as an html page, and I'd like to use FileReader to read the file contents into a jquery-csv's To Arrays function, but I can't seem to get it to work properly. I think I understand the asynchrony of this task, but...

Read streamfile in java

java,file,csv,filestream,filereader
I am working on comma separated value file.i want to extract first position["0" place in array] value from each raw and want to some math calculation on it. csv inputfile is like this a,b,c,d 12,32,45,76 23,45,77,56 32,34,49,28 73,92,26,68 73,36,77,26 for getting first position it give me error like this Exception...

getting two consicutive value from file in java

java,file,csv,stream,filereader
I am working with a csv file, and I want to extract two values in specific positions from each and every row. The csv input file looks like this: a, b, c, d 12,32,45,76 23,45,77,56 32,34,49,28 73,92,26,68 73,36,77,26 For example I want the two consecutive values from the 3rd position...

How to copy content of a file to another file but at the top of the file in Java [duplicate]

java,file,filereader,fileinputstream,filewriter
This question already has an answer here: Java. How to append text to top of file.txt [duplicate] 3 answers I would liked to copy the content of file "Convert.sql" to file "Entity.sql" without overriding the "Entity.sql" file. This part i've been able to do it but in addition to...

FlatFileParseException Spring batch

spring-batch,filereader
I am getting flat file parse exception when i use FlatFileItemReader in my job configuration. Actually it was working fine, but with recent files its throwing error. org.springframework.batch.item.file.FlatFileParseException: Parsing error at line: 1 in resource=[URL [file:/prod/users/cdi/crh537/Java_All/input/xaaaaa]], input=[16910203315393417SEVAN Q DANG18711 PARK GROVE [email protected]MAR CL197311192013042504Closed (zero balance DDA)220PUSA] The main difference is...

chrome.local.storage save directory info and retrieve this information

html5,google-chrome,google-chrome-app,filereader
Is it possible to save information from a directory with chrome.local.storage and subsequently retrieve this information to display the files contained inside. Thank you in advance!...

Can the ouput of a HTML5 FileReader.readAsDataURL be used to reference fonts?

javascript,html5,fonts,filereader
I have a HTML5 image editor that I'd like to enable custom fonts uploaded by the user. I'd like to use the HTML5 FileReader.readAsDataURL to store the font provided by the user in the database. After storing it in the db I'd like to be able to then reference those...

How to read files in java?

java,file,filereader,maze
I made this maze solver program and all of it works except for the "file reader". What I intend to do is that the file has a maze map with 1 as a wall, 0 as a pass you can go, 3 is start and 9 is the finish line....

Very strange character replacing bug in Python

python,io,filereader
I have a TXT file where I want to replace ';' characters to space in every line. Here is the code: input_file = open('input.txt', 'r') output_file = open('output.txt', 'w') for line in input_file: s=line.read() s.replace(';', ' ') output_file.write(s) It gives that error: AttributeError: 'str' object has no attribute 'read' What...

Program Reading Last Line of File Twice [duplicate]

c,filereader
This question already has an answer here: Why is “while ( !feof (file) )” always wrong? 7 answers I am writing a program that reads a .txt file line by line. I have been able to do this so far, but the last line of the file is read...

AngularJS Problems with FileReader and $scope.$watch?

javascript,angularjs,filereader
I've got a weird one (for me at least) that hopefully someone will be able to help with. Maybe I'm just thinking about this the wrong way or something. Attempting to work with files in javascript is completely new to me. I've got a directive whose template looks like this:...

java repeat one part of the output

java,eclipse,io,filereader,java-io
I have Java assignment , and this is the explanation of the In your program create three classes: InputHandler, OutputHandler and Student classes. The InputHandler class handles the reading of information from the input file. It also contains an array of Student objects to store the information in it. The...

Add promise result to items in array

javascript,asynchronous,filereader
What i've been trying to do is add the files and their matching dataurl into objects in an array. Files is a FileList object. I first tried this inside the onloadend event of the Filereader but couldn't access the original file during reading so moved onto promises. var data =...

Synchronous Read of Local File using Javascript

javascript,filereader,synchronous
I have a data file, newline delimited, of a variety of names I want to pull into an array for processing in JavaScript. This set of names will eventually need to be sorted, but right now I'm working on the actual file loading process. Here is my code as it...

Dealing with FileReader and subString

java,substring,filereader
I'm trying to read a file .txt which contains 8 lines of Stores in different regions. Each line has 15 characters. When I run this code, just the first line is printed and afterwards it throws this: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 10 at java.lang.String.substring(String.java:1951)...

How can i move rotated canvas image whitout disorientation?

javascript,jquery,canvas,html5-canvas,filereader
I have an image loaded into the canvas. I can't (drag) move the image properly, after it is rotated. Actually, it moves but it moves based on the image's coordinate plane. So moving a 90 degree rotated image to the right, moves down and not to the right as expected....

Drawing an image in its full size in a canvas works only on the second try in Mozilla Firefox

javascript,html,firefox,canvas,filereader
I'm trying to get images from users and draw in them stuff. But I'm getting strange behaviour in MF to only show the image in its full size in a canvas. I have the following code: <!DOCTYPE html> <html> <body> <input type="file" id="input"> <div id="main"></div> <script> document.getElementById('input').onchange = function() {...

Get file type after sending the file from WebRTC

javascript,download,webrtc,filereader
I am using WebRTC to get two clients communicated using peer.js var peer = new Peer( { key: "XXX", config: {"XXX": [{ url: "XXXXXXX" }]} }); My main aim is to send file from one client to another. For that I am using following code: $("#box").on("drop", function(e) { e.originalEvent.preventDefault(); var...

return value calculated from javascript FileReader onload event

javascript,callback,onload,filereader
I have this function: function doStuff(range, file) { var fr = new FileReader(); var hash = ''; fr.onload = function (e) { var out = "stuff happens here"; hash = asmCrypto.SHA256.hex(out); return hash; }; fr.readAsArrayBuffer(file); return hash; } Right now, the function completes before the onload event is finished, so...

File Reader Method

java,logic,bufferedreader,filereader
So I wrote this file reader method that should return a string of everything that is in the file, but it isn't working properly. Writing into the file works perfectly, but this reading method doesn't. What the method does currently is it reads the last string/text added, but it does...

Understanding how BufferedReader works in Java

java,bufferedreader,filereader
Very basic question on how BufferedReader works. Given the string/phrase, i want to find and print it from the file with a lot of text in it. using BufferedReader in Java I did some research on this topic and that was the closest result. Not quite adressing my problem though....