Java – get the newest file in a directory?

The following code returns the last modified file or folder: public static File getLastModified(String directoryFilePath) { File directory = new File(directoryFilePath); File[] files = directory.listFiles(File::isFile); long lastModifiedTime = Long.MIN_VALUE; File chosenFile = null; if (files != null) { for (File file : files) { if (file.lastModified() > lastModifiedTime) { chosenFile = file; lastModifiedTime = file.lastModified(); … Read more

Where does PERSISTENT file system storage store with chrome?

For me, at least on Mac OSX, they’re stored under /Users/USERNAME/Library/Application Support/Google/Chrome/Default/File System for me. If you’re using profiles, there will be profile directories instead of Default. However, each origin’s saved files/folders are obfuscated under directories that won’t be easy for you to interact with. For debugging the Filesystem API, you have a few options: … Read more

Java in Eclipse: Where do I put files on the filesystem that I want to load using getResource? (e.g. images for an ImageIcon)

For Eclipse, typically all you need to do is set up a folder somewhere within your source code directory. For instance, if the directory containing your source is /src then you can create a /src/resources folder to place your images/files in. Then, within your class you do a getResource(“/resources/image.png”) to retrieve it. You can also … Read more

Storing a large number of images

We had a similar problem in the past. And found a nice solution: Give each image an unique guid. Create a database record for each image containing the name, location, guid and possible location of sub images (thumbnails, reducedsize, etc.). Use the first (one or two) characters of the guid to determine the toplevel folder. … Read more

nodejs – How to read and output jpg image?

Here is how you can read the entire file contents, and if done successfully, start a webserver which displays the JPG image in response to every request: var http = require(‘http’) var fs = require(‘fs’) fs.readFile(‘image.jpg’, function(err, data) { if (err) throw err // Fail if the file can’t be read. http.createServer(function(req, res) { res.writeHead(200, … Read more

Python causing: IOError: [Errno 28] No space left on device: ‘../results/32766.html’ on disk with lots of space

The ENOSPC (“No space left on device”) error will be triggered in any situation in which the data or the metadata associated with an I/O operation can’t be written down anywhere because of lack of space. This doesn’t always mean disk space – it could mean physical disk space, logical space (e.g. maximum file length), … Read more