Good C string library [closed]

It’s an old question, I hope you have already found a useful one. In case you didn’t, please check out the Simple Dynamic String library on github. I copy&paste the author’s description here: SDS is a string library for C designed to augment the limited libc string handling functionalities by adding heap allocated strings that … Read more

java file input with rewind()/reset() capability

I think the answers referencing a FileChannel are on the mark . Here’s a sample implementation of an input stream that encapsulates this functionality. It uses delegation, so it’s not a true FileInputStream, but it is an InputStream, which is usually sufficient. One could similarly extend FileInputStream if that’s a requirement. Not tested, use at … Read more

Reading inputStream using BufferedReader.readLine() is too slow

I strongly suspect that’s because of the network connection or the web server you’re talking to – it’s not BufferedReader‘s fault. Try measuring this: InputStream stream = conn.getInputStream(); byte[] buffer = new byte[1000]; // Start timing while (stream.read(buffer) > 0) { } // End timing I think you’ll find it’s almost exactly the same time … Read more

Beginner Python: Reading and writing to the same file

Updated Response: This seems like a bug specific to Windows – http://bugs.python.org/issue1521491. Quoting from the workaround explained at http://mail.python.org/pipermail/python-bugs-list/2005-August/029886.html the effect of mixing reads with writes on a file open for update is entirely undefined unless a file-positioning operation occurs between them (for example, a seek()). I can’t guess what you expect to happen, but … Read more

Haskell IO and closing files

As others have stated, it is because of lazy evaluation. The handle is half-closed after this operation, and will be closed automatically when all data is read. Both hGetContents and readFile are lazy in this way. In cases where you’re having issues with handles being kept open, typically you just force the read. Here’s the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)