What is the fastest method for reading from a text file in Java?
I currently use: BufferedReader input = new BufferedReader(new FileReader("filename")); Is there a faster way? ...
I currently use: BufferedReader input = new BufferedReader(new FileReader("filename")); Is there a faster way? ...
I have the following code which reads in the follow file, append a \r\n to the end of each line and puts the result in a string buffer: public InputStream getInputStream() throws Exception { StringBuffer holder = new StringBuffer(); try{ FileInputStream reader = new FileInputStream(inputPath); BufferedReader br = new Buffe...
If I want to check how many files there are in a folder (where there is likely to be 10,000+ files), is there a more efficient way than... Public Function FileCount(FolderName as String) As Integer Dim Files() As String Files = IO.Directory.GetFiles(FolderName) Return Files.Length End Function It seems to be unweildly...
I'm pretty new to programming, so be gentle. I'm trying to extract IBSN numbers from a library database .dat file. I have written code that works, but it is only searching through about half of the 180MB file. How can I adjust it to search the whole file? Or how can I write a program the will split the dat file into manageable chunks? e...
I want to read lines from a file into a Set or List. Is there a standard utility for doing this? If these lines are of the form [key]=[value] I can do: Properties properties = new Properties(); properties.load(new FileInputStream(file)); The values are single entries, one per line, each value becomes an entry in the Set/List I know ...
After building a filepath (path, below) in a string (I am aware of Path in System.IO, but am using someone else's code and do not have the opportunity to refactor it to use Path). I am using a FileStream to deliver the file to the user (see below): FileStream myStream = new FileStream(path, FileMode.Open, FileAccess.Read); long fileSi...
As many of you know, the System.IO namespace is abysmally designed. I would like a free library that wraps the file IO functionality in a sane way (read: doesn't require you passing strings all over the place). I remember reading some time ago that there is a small handful of these libraries already written (and the author was surprise...
I am working on a content management application in which the data being stored on the database is extremely generic. In this particular instance a container has many resources and those resources map to some kind of digital asset, whether that be a picture, a movie, an uploaded file or even plain text. I have been arguing with a colle...
I am doing an archive service for logs. Since some files are open and in use I can't archive them until they are not in use anymore. The only way I can figure out how to see if the file is open by another process is the code below. I hate the code there must be a better way. Is there a better way? try { using (FileStream stream ...
Hi , I want to write a structure which has a list of integer id. The list can be of varying length. typedef struct ss_iidx_node { int totalFreq; vector < int > docIDList; }s_iidx_node; Now, I wish to write this structure in a file and read it back. How can I do it? Wrting is done: fwrite(&obj,sizeof(s_iidx_node),1,dat_fd...
I'd like to open the same file for both reading and writing. The file pointer should be independent. So a read operation should not move the write position and vice versa. Currently, I'm using this code: FileStream fileWrite = File.Open (path, FileMode.OpenOrCreate, FileAccess.Write, FileShare.Read); FileStream fileRead = File.Open (pa...
Our .NET app copies large files, and needs to give the user feedback; so rather than use File.Copy we read a chunk of one file and write it to the other, and display the progress after each chunk. Nothing out of the ordinary. But what's the right size of chunk to use, to give the fastest file copy, assuming the time to display the prog...
I have the following class subclass of FilterInputStream with only one method overrided. However the performance of this class is so poor. It performs at 1/10 the speed of its superclass. I even took the same source code from InputStream of javasrc and used it in my subclass. Same performance hit. Is there something wrong with overriding...
Right now I am working on a stub of a project. In the course of the project I need to be able to from a web front end set a message on a server to and then from an iPhone Query the Server to read the message. While all the individual peices are working and my request is going through fine I am having trouble using this webmethod [Web...
We have some ancient Delphi code (might have even originated as Turbo Pascal code) that uses {$I-}, aka {$IOCHECKS OFF}, which makes the code use IOResult instead of exceptions for disk I/O errors. I want to get rid of the {$I-} and bring this code forward into the 1990s, but to do that, I'd like to know what all is affected by {$IOCHE...
I have a C++ application running on Windows that wakes up every 15 mins to open & read files present in a directory. The directory changes on every run. open is performed by *ifstream.open(file_name, std::ios::binary)* read is performed by streambuf ios::rdbuf()* Total number of files every 15 mins is around 50,000 The files are opene...
Hello, I'm trying to make a small program that could intercept the open process of a file. The purpose is when an user double-click on a file in a given folder, windows would inform to the software, then it process that petition and return windows the data of the file. Maybe there would be another solution like monitoring Open messag...
Hello, I'm trying to know how to save a content of a TextField to a File, like a .txt, using a Common Dialog, only a command dialog in Visual Basic 6, i need this using a only a common dialog, because i'm trying to do the same aplication in eVB, and eVB does not support this methods: Dim objFSO As New Scripting.FileSystemObject D...
How can I make a program, like wget, such that the user can download files by typing the following? $ wget http://www.testpage.com/file.pdf And the program downloads the file. I want this syntax, my program name and the site, then the user press enter and my program start the file download. Please if you are going to post the code, ...
I have written a simple WCF service that accepts and stores messages. It works fine when hosted locally. I still works when hosted on IIS 6. But when I enable the service's ability to store the messages to xml I get the following error: Access to c:\windows\system32\inetsrv\Onno.xml has been denied (translated from dutch, so may not matc...