filereader

Counting distinct words with Threads

独自空忆成欢 提交于 2019-12-02 07:42:48
The objective is to count distinct words from a file. UPDATE: Previous Code was successfully finished. Now I have to do the same but using threads (Oh man, I hate them...) and in addition I want to make it with semaphores for better flow. Code contains some extra stuff left out from previous attempts, I'm trying to figure out what can be used.. I can read one word at a time but mostly I get a "null" in the container. So until I get anything from the container all the time I can't test the Sorter class and so on... The new addition to the program is WordContainer class to store one word to pass

Netbeans FileReader FileNotFound Exception when the file is in folder?

主宰稳场 提交于 2019-12-02 05:54:35
问题 so the problem is that I am having exception thrown each time I try to load the code below on NetBeans or Eclips, but when I try to run it thru TextMate everything works fine! I tried to put the absolute address, changed the text file etc.. didn't help! Can someone help me or tell why it won't run with IDE? Thanks void loadFile() { try { list = new LinkedList<Patient>(); FileReader read = new FileReader("a.txt"); Scanner scan = new Scanner(read); while (scan.hasNextLine()) { String Line =

Java 字节流操作2

99封情书 提交于 2019-12-02 05:28:25
上篇文章 Java 字节流操作 介绍了java中基本的字节流操作,但是我们常常对于字符操作,如果使用字节流来实现输入输出就显得麻烦,我们可以使用字符流来实现对我们看得见的字符char进行操作,主要内容如下: 基本流(Reader/Writer) 转换流(InputStreamReader/OutputStreamEWriter) 文件字符流(FileReader/FileWriter) 字符数组流(charArrayReader/charArrayWriter) 缓冲字符流(BufferedReader/BufferedWriter) 装饰类(PrintWriter) 一、基本流 字节流的基本流是InputStream/OutputStream,这里的字符流的基本流是Reader/Writer,他们都是抽象类,想要实现更加复杂的操作就必须要子类来扩充。他们内部主要的就是read和write方法,实现单个字符及字符数组的读取的写入。此处就不再列出,我们将会从他们的子类中看看这些方法的实现。 二、转换流 InputStreamReader和OutputStreamWriter这两个类型流,在整个字符流中是十分重要的流,他们实现了和字节流的转换。先看看InputStreamReader: private final StreamDecoder sd; public

记录在做大文件上传的过程中遇到的问题

浪尽此生 提交于 2019-12-02 05:09:20
1、413 request Entity too Large 问题:访问分片接口的时候浏览器返回413 排查:跟后端同学排查发现后段接口能收到请求并且成功 可能出现在两个阶段: 1、node起服务代理的时候 2、中间代理转发的时候设置 client_max_body_size 20m; 2、关于文件夹上传 webkitdirectory ='' 启动文件夹上传 webkitdirectory ='false' 仍然是可以做文件夹上传 如果非文件夹上传直接不加这个属性即可 3、关于文件的分片 /** * 获取分片信息 */ getChunkInfo = (file, start, end) => { // console.log("getChunkInfo getChunkInfo index") return new Promise((resolve, reject) => { // console.log("getChunkInfo Promise") const targetChunk = file.slice(start, end); const spark = new SparkMD5.ArrayBuffer(); const fileReader = new FileReader(); fileReader.onload = e => { const chunk =

java I/O学习

梦想的初衷 提交于 2019-12-02 02:51:14
java I/O java的输入输出系统 所有的数据都是通过流在各个设备上转运传输 磁盘文件 File 主要处理文件及文件系统(目录)这个 比较特殊,不属于流式操作 文件信息 isFile(),listFiles(),getName(),exists() getPath(),getAbsolutePath(),getParent() 目录信息 isDirectory(),list() 流式输入/输出建立在四个抽象类的基础上 1.InputStream 字节流 2.OutputStream 3.Reader 字符流 4.Writer 处理字节或二进制对象使用 字节流 处理字符、字符串对象使用 字符流 字节流 InputStream,OutputStream 字节流的类使用装饰器来实现(decorator pattern) 1.FileInputStream(文件输入流) FileInputStream f1=new FileInputStream("/Usrs/local.bat"); // 这个实现更好,进一步的文件检查,公开读取 File f=new File("/Usrs/local.bat"); FileInputStream fis=new FileInputStream(f); 2.ByteArrayInputStream(字节数组输入流) 实现mark()和reset(

文件转base64处理

霸气de小男生 提交于 2019-12-02 02:37:39
一、代码: axios({ method: 'get', url: apiPath.common.downloaddUrl, responseType: 'blob'}).then(res => {  console.log(res) if (res && res.data && res.data.size) { const dataInfo = res.data let reader = new FileReader() reader.readAsDataURL(dataInfo) reader.onload = function (e) { const result = e.target.result    console.log(result) // 打印base64链接 } }})二、关键点:1、在一个请求中添加 responseType 为 blob2、利用 new FileReader() 处理转化获得 来源: https://www.cnblogs.com/waitingbar/p/11726295.html

java读取地址数据文件

送分小仙女□ 提交于 2019-12-02 02:02:56
在工作中遇到读取地址文件数据: 1、读取本地文件数据(如:D:\data.txt) //适用于读取绝对地址文件 public String getData(String path) { String str = ""; try { File file = new File(path);// 定义一个file对象,用来初始化FileReader FileReader reader = new FileReader(file);// 定义一个fileReader对象,用来初始化BufferedReader BufferedReader bReader = new BufferedReader(reader);// new一个BufferedReader对象,将文件内容读取到缓存 StringBuilder sb = new StringBuilder();// 定义一个字符串缓存,将字符串存放缓存中 String s = ""; while ((s = bReader.readLine()) != null) {// 逐行读取文件内容,不读取换行符和末尾的空格 sb.append(s + "\n");// 将读取的字符串添加换行符后累加存放在缓存中 System.out.println(s); } bReader.close(); str = sb.toString(); return

Reading from files passed as command line arguements

折月煮酒 提交于 2019-12-02 01:37:47
I am trying to parse a given textfile, but so far, my program does not seem to be reading properly. #include <stdio.h> int main(int argc, char *argv[]) { FILE *fr; //file pointer int buildingFloors = 1; printf("sanity check\n"); fr = fopen (argv[0], "r"); fscanf(fr, "%d", &buildingFloors ); printf("%d\n", buildingFloors); fclose(fr); return 0; } I compile the program and run it on my redhat linux machine with the following command: ./sjf file.text file.text is a text document with a "4" as the first character. So I would expect my output to be sanity check 4 However, when I run my program I

Netbeans FileReader FileNotFound Exception when the file is in folder?

♀尐吖头ヾ 提交于 2019-12-02 00:41:15
so the problem is that I am having exception thrown each time I try to load the code below on NetBeans or Eclips, but when I try to run it thru TextMate everything works fine! I tried to put the absolute address, changed the text file etc.. didn't help! Can someone help me or tell why it won't run with IDE? Thanks void loadFile() { try { list = new LinkedList<Patient>(); FileReader read = new FileReader("a.txt"); Scanner scan = new Scanner(read); while (scan.hasNextLine()) { String Line = scan.nextLine(); String[] subArray = new String[5]; subArray = Line.split(","); int a = Integer.parseInt

html5对于文件的相关操作

只愿长相守 提交于 2019-12-02 00:33:50
今天在写前端的时候碰到一些问题,现在对于web网页操作文件进一步了解。 主要参照: http://www.cnblogs.com/zichi/p/html5-file-api.html FileList 对象针对表单的 file 控件。当用户通过 file 控件选取文件后,这个控件的 files 属性值就是 FileList 对象。它在结构上类似于数组,包含用户选取的多个文件。如果 file 控件没有设置 multiple 属性,那么用户只能选择一个文件,FileList 对象也就只有一个元素了。 <input type='file' multiple/> <script> document.querySelector('input').onchange = function () { console.log(this.files); }; </script> 控制台输出文件相关内容。 Blob 上图中我们看到,File 对象是继承自 Blob 对象的,Blob 又是什么鬼? Blob(Binary Large Object)对象代表了一段二进制数据,提供了一系列操作接口。其他操作二进制数据的 API(比如 File 对象),都是建立在 Blob 对象基础上的,继承了它的属性和方法。 生成 Blob 对象有两种方法:一种是使用 Blob 构造函数,另一种是对现有的 Blob