/** Write any dirty properties down to disk */ protected void flushProperties() throws IOException { if (dirtyProperties) { final String propertiesFilename = path + ApplicationSetup.FILE_SEPARATOR + prefix + PROPERTIES_SUFFIX; if ((Files.exists(propertiesFilename) && !Files .canWrite(propertiesFilename)) || (!Files.exists(propertiesFilename) && !Files .canWrite(path))) { logger.warn("Could not write to index properties at " + propertiesFilename + " because you do not have write permission on the index - some changes may be lost"); return; } final OutputStream outputStream = Files .writeFileStream(propertiesFilename); properties.store(outputStream, this.toString()); outputStream.close(); dirtyProperties = false; } }
public ByteOutputStream(String filename) throws IOException { OutputStream file; try{ file = Files.writeFileStream(filename); init(file); } catch(FileNotFoundException fnfe) { final String dir = Files.getParent(filename); logger.warn("Could not open new ByteOutputStream because it alleged file could not be found.", fnfe); if (logger.isDebugEnabled()) logger.debug("File.canRead()="+Files.canWrite(filename)+ "Dir.exists()=" +Files.exists(dir) + " Dir.canWrite()="+Files.canWrite(dir) +" Dir.contentsSize="+Files.list(dir).length); sleep(1000); if (logger.isDebugEnabled()) logger.debug("File.canRead()="+Files.canWrite(filename)+ "Dir.exists()=" +Files.exists(dir) + " Dir.canWrite()="+Files.canWrite(dir)+" Dir.contentsSize="+Files.list(dir).length); logger.warn("Retrying to write BitOutputStream."); init(Files.writeFileStream(filename)); logger.info("Previous warning can be ignored, BitOutputStream "+filename+" has opened successfully"); } }
/** Write any dirty properties down to disk */ protected void flushProperties() throws IOException { if (dirtyProperties) { final String propertiesFilename = path + ApplicationSetup.FILE_SEPARATOR + prefix + PROPERTIES_SUFFIX; if ((Files.exists(propertiesFilename) && !Files .canWrite(propertiesFilename)) || (!Files.exists(propertiesFilename) && !Files .canWrite(path))) { logger.warn("Could not write to index properties at " + propertiesFilename + " because you do not have write permission on the index - some changes may be lost"); return; } final OutputStream outputStream = Files .writeFileStream(propertiesFilename); properties.store(outputStream, this.toString()); outputStream.close(); dirtyProperties = false; } }
/** * Constructs an instance of the class for a given filename * Note that on a FileNotFoundException, this contructor will sleep for 2 seconds * before retrying to open the file. * @param filename String with the name of the underlying file * @throws java.io.IOException if an I/O error occurs */ public BitOutputStream(String filename) throws IOException { try{ dos = new DataOutputStream(Files.writeFileStream(filename)); } catch(FileNotFoundException fnfe) { final String dir = Files.getParent(filename); logger.warn("Could not open new BitOutputStream because it alleged file could not be found.", fnfe); if (logger.isDebugEnabled()) logger.debug("File.canRead()="+Files.canWrite(filename)+ "Dir.exists()=" +Files.exists(dir) + " Dir.canWrite()="+Files.canWrite(dir) +" Dir.contentsSize="+Files.list(dir).length); sleep(1000); if (logger.isDebugEnabled()) logger.debug("File.canRead()="+Files.canWrite(filename)+ "Dir.exists()=" +Files.exists(dir) + " Dir.canWrite()="+Files.canWrite(dir)+" Dir.contentsSize="+Files.list(dir).length); logger.warn("Retrying to write BitOutputStream."); dos = new DataOutputStream(Files.writeFileStream(filename)); logger.info("Previous warning can be ignored, BitOutputStream "+filename+" has opened successfully"); } init(); }
public ByteOutputStream(String filename) throws IOException { OutputStream file; try{ file = Files.writeFileStream(filename); init(file); } catch(FileNotFoundException fnfe) { final String dir = Files.getParent(filename); logger.warn("Could not open new ByteOutputStream because it alleged file could not be found.", fnfe); if (logger.isDebugEnabled()) logger.debug("File.canRead()="+Files.canWrite(filename)+ "Dir.exists()=" +Files.exists(dir) + " Dir.canWrite()="+Files.canWrite(dir) +" Dir.contentsSize="+Files.list(dir).length); sleep(1000); if (logger.isDebugEnabled()) logger.debug("File.canRead()="+Files.canWrite(filename)+ "Dir.exists()=" +Files.exists(dir) + " Dir.canWrite()="+Files.canWrite(dir)+" Dir.contentsSize="+Files.list(dir).length); logger.warn("Retrying to write BitOutputStream."); init(Files.writeFileStream(filename)); logger.info("Previous warning can be ignored, BitOutputStream "+filename+" has opened successfully"); } }
/** * Constructs an instance of the class for a given filename * Note that on a FileNotFoundException, this contructor will sleep for 2 seconds * before retrying to open the file. * @param filename String with the name of the underlying file * @throws java.io.IOException if an I/O error occurs */ public BitOutputStream(String filename) throws IOException { try{ dos = new DataOutputStream(Files.writeFileStream(filename)); } catch(FileNotFoundException fnfe) { final String dir = Files.getParent(filename); logger.warn("Could not open new BitOutputStream because it alleged file could not be found.", fnfe); if (logger.isDebugEnabled()) logger.debug("File.canRead()="+Files.canWrite(filename)+ "Dir.exists()=" +Files.exists(dir) + " Dir.canWrite()="+Files.canWrite(dir) +" Dir.contentsSize="+Files.list(dir).length); sleep(1000); if (logger.isDebugEnabled()) logger.debug("File.canRead()="+Files.canWrite(filename)+ "Dir.exists()=" +Files.exists(dir) + " Dir.canWrite()="+Files.canWrite(dir)+" Dir.contentsSize="+Files.list(dir).length); logger.warn("Retrying to write BitOutputStream."); dos = new DataOutputStream(Files.writeFileStream(filename)); logger.info("Previous warning can be ignored, BitOutputStream "+filename+" has opened successfully"); } init(); }