filereader

Java day10 IO FileReader,Properties 待补充

末鹿安然 提交于 2019-12-08 05:11:39
import java.io.*; import java.util.*; class FileReaderDemo { public static void main(String[] args) throws IOException { //文件字符流 //写路径名时注意不同层级间用双斜线 FileReader fr=new FileReader("E:\\代码\\day10\\IOtestDemo_1\\1.txt"); //传入 字符方式 //fr.read()读取单个字符,返回int型数据,执行一次,文件内访问指针后一一位 //当 当前文件内访问字符指针到达文件结尾时,返回-1(EOF),类似于c中的fgetc() int ch=0; while((ch=fr.read())!=-1) { System.out.print((char)ch); } //fr.reset();//???? fr.close(); //int n=3; //char []a=new char[n]; //传入字符数组方式 //read([]char)将接收到的字符传给数组,返回传入的字符的个数 FileReader fr1=new FileReader("E:\\文档\\IC卡.cpp"); char []buf=new char[1024];// int num;//传入的个数 while

Problem with Java FileReader [duplicate]

一世执手 提交于 2019-12-08 04:32:39
问题 This question already has answers here : FileNotFoundException, the file exists Java [closed] (2 answers) Closed 3 years ago . Hello I have this in my code File file = new File("words.txt"); Scanner scanFile = new Scanner(new FileReader(file)); ArrayList<String> words = new ArrayList<String>(); String theWord; while (scanFile.hasNext()){ theWord = scanFile.next(); words.add(theWord); } But for some reason I am getting a java.io.FileNotFoundException I have the words.txt file in the same

What's the safest way to use FileReader with iOS8?

强颜欢笑 提交于 2019-12-08 02:55:48
问题 I have a form that has file selector. <input type="file" ... Run the code snippet below to see what it does. On Safari on iOS8 there is a known bug that means you cannot read file content with FileReader. This only happens on real hardware, the iOS simulator works fine. On Chrome on iOS8 this code sometimes just completely crashes the browser. I don't want to use agent sniffing to decide whether or not to attempt the function. Is there a better way to write this so that I can gracefully

How to read a specific position of a string data in a text file

…衆ロ難τιáo~ 提交于 2019-12-08 02:28:29
问题 I am processing a text file which contains up to a thousand lines. There are multiple headers and footers in one text file. So I don't need to process the line which contains @h and @f. It tells me the beginning and end of a transaction (Database transaction, I will save those records to DB in one transaction). A sample record is below. Though the line reaches up to a thousand lines and the columns are up to 40 columns. From each line I am only looking for a specific data i.e (e.g i need to

JavaScript for loop on files FileReader

你说的曾经没有我的故事 提交于 2019-12-07 23:22:41
问题 The problem is breaking my mind. Can someone help me? In the <script> tag in my html file I have this: window.ondragover = function(e){return false;} window.ondragenter = function(e){return false;} window.ondrop = function(e){ var files = e.target.files || e.dataTransfer.files; for (var i = 0, file; file = files[i];i++){ var img = document.createElement('img'); img.height = 200; img.width = 200; img.style.background = 'grey'; document.body.appendChild(img); var reader = new FileReader();

Failed to load resource: net::ERR_FILE_NOT_FOUND uploading files bigger than 500Mb

馋奶兔 提交于 2019-12-07 22:42:46
问题 I have a problem uploading files bigger than 500Mb. I created a plunker file with error code: https://plnkr.co/edit/vKHNkUuVX1RrMcZ6Ezhc?p=preview var request = new XMLHttpRequest(); request.open("POST", "/uploadFile"); request.send(formData); request.addEventListener("progress", function(evt) { if (evt.lengthComputable) { console.log(evt.loaded / evt.total); } else { console.log('Undefined percent...'); } }, false); request.addEventListener("load", function(evt) { console.error(evt); },

Trying to upload multiple images using XHR 2 and PHP

一笑奈何 提交于 2019-12-07 19:04:28
I'm having problems trying to upload files using the latest XHR 2 along with PHP. My code is as follows: HTML... <!doctype html> <html> <head> <title>XHR Multiple File Upload</title> <link rel="stylesheet" type="text/css" href="upload.css"> </head> <body> <input type="file" id="upload" multiple="true" accept="image/*"> <a href="#" id="upload-link">Click here to upload multiple files</a> <script src="upload.js"></script> </body> </html> JavaScript var formdata, link, input, doc = document; if (window.FormData) { formdata = new FormData(); } function init(){ link = doc.getElementById("upload

addEventListener with inexplicable undefined method error

旧巷老猫 提交于 2019-12-07 15:06:44
问题 I couldn't find an answer to this problem I've been having. function UploadBar() { this.reader = new FileReader(); this.reader.addEventListener( "onloadstart" , function(evt) {alert("Hello World");} , false ); } when I try to run this code it gives me an undefined_method_error in the javascript debugger in chrome. Could anyone be so kind as to tell me what is wrong here? 回答1: reader is not an element, so don't use .addEventListener Instead do the following. function UploadBar() { this.reader

Node readline module doesn't have 'on' function?

痴心易碎 提交于 2019-12-07 06:13:37
问题 I'm trying to create a node app that reads a textfile line by line using the 'readline' module, and prints it to the console. var lineReader = require('readline'); lineReader.createInterface({ input: fs.createReadStream('./testfile') }); lineReader.on('line', function(line){ console.log(line); }); According to the module's documentation, there should be an 'on' method. However when I log the instance of the readline object I created, I don't see an 'on' method anywhere: { createInterface:

How to read line by line by using FileReader

断了今生、忘了曾经 提交于 2019-12-07 03:19:51
问题 Thank you for your attention. I have created a program which I'm using a Login form and Register form. Once users register their email and their password will be saved it into submit.txt . Then they will turn back to login form and enter their email and password which are saved into submit.txt . In my code, I'm using write file for Register form, and Read file for Login Form. But, it doesn't work. I know my problem in the code used for Read File. May you help me to realize that?. Thank you