Write value to file

@param forceSync if true data must be synced to disk
@throws IOException
503991
public synchronized void write(final boolean forceSync) throws IOException {
		if (!validState) {
			throw new InvalidStateException();
		}
		buf.clear();
		buf.putLong(value);
		buf.flip();
		fc.position(fc.size()).write(buf); // go end and write
		if (forceSync) {
			fc.force(false);
		}
	}
973375
function(key, val, isSync, fn) {
    var filepath = this._makeFilepath(key);

        // Create cache key
    var cache = {
      ttl: new Date(Date.now() + this.ttl),
      data: val
    };

    var data = JSON.stringify(cache);
    var  method = isSync ? 'writeFileSync' : 'writeFile';
    var args = [filepath, data, 'UTF8', isSync ? null : fn];

    return fs[method].apply(fs, args);
  }
1259802
public static void save( File f, ApplicationTemplateDescriptor descriptor ) throws IOException {

		Properties properties = new Properties();
		if( descriptor.name != null )
			properties.setProperty( APPLICATION_NAME, descriptor.name );

		if( descriptor.version != null )
			properties.setProperty( APPLICATION_VERSION, descriptor.version );

		if( descriptor.dslId != null )
			properties.setProperty( APPLICATION_DSL_ID, descriptor.dslId );

		if( descriptor.description != null )
			properties.setProperty( APPLICATION_DESCRIPTION, descriptor.description );

		if( descriptor.graphEntryPoint != null )
			properties.setProperty( APPLICATION_GRAPH_EP, descriptor.graphEntryPoint );

		if( descriptor.instanceEntryPoint != null )
			properties.setProperty( APPLICATION_INSTANCES_EP, descriptor.instanceEntryPoint );

		if( descriptor.externalExportsPrefix != null )
			properties.setProperty( APPLICATION_EXTERNAL_EXPORTS_PREFIX, descriptor.externalExportsPrefix );

		StringBuilder sb = new StringBuilder();
		for( Iterator<Map.Entry<String,String>> it = descriptor.externalExports.entrySet().iterator(); it.hasNext(); ) {
			Map.Entry<String,String> entry = it.next();
			sb.append( entry.getKey());
			sb.append( " " );
			sb.append( APPLICATION_EXTERNAL_EXPORTS_AS );
			sb.append( " " );
			sb.append( entry.getValue());
			if( it.hasNext())
				sb.append( ", " );
		}

		if( sb.length() > 0 )
			properties.setProperty( APPLICATION_EXTERNAL_EXPORTS, sb.toString());

		properties.setProperty( APPLICATION_TAGS, Utils.format( descriptor.tags, ", " ));
		Utils.writePropertiesFile( properties, f );
	}
9574
public void writeFile(String filePath, byte[] data) throws IOException
   {
      Object lock = retrieveLock(filePath);      
      synchronized (lock) 
      {
         IO.writeFile(filePath, data);
      }
   }
1135907
def write(self, value):
        
        aio_block = libaio.AIOBlock(
            mode=libaio.AIOBLOCK_MODE_WRITE,
            target_file=self.getEndpoint(1),
            buffer_list=[bytearray(value)],
            offset=0,
            eventfd=self.eventfd,
            onCompletion=self._onCanSend,
        )
        self._aio_send_block_list.append(aio_block)
        self._aio_context.submit([aio_block])
        if len(self._aio_send_block_list) == MAX_PENDING_WRITE_COUNT:
            self._onCannotSend()
1142741
public static void writeObject(File file, Object object) throws IOException {
        FileOutputStream fileOut = new FileOutputStream(file);
        ObjectOutputStream out = new ObjectOutputStream(new BufferedOutputStream(fileOut));
        try {
            out.writeObject(object);
            out.flush();
            // Force sync
            fileOut.getFD().sync();
        } finally {
            IoUtils.safeClose(out);
        }
    }
831896
public void forceSet(byte[] newValue) throws Exception
    {
        try
        {
            client.setData().forPath(path, newValue);
        }
        catch ( KeeperException.NoNodeException dummy )
        {
            try
            {
                client.create().creatingParentContainersIfNeeded().forPath(path, newValue);
            }
            catch ( KeeperException.NodeExistsException dummy2 )
            {
                client.setData().forPath(path, newValue);
            }
        }
    }
870152
void writeLock(int count) {
      if (count > 0 && counter != null)
         counter.acquireShared(count);
      sync.acquireShared(1);
   }
937986
function forceSync() {
  var donePromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC, CONSTANTS.DONE_PREFIX));

  var errorPromise = mediator.promise(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC, CONSTANTS.ERROR_PREFIX));

  mediator.publish(resultSyncSubscribers.getTopic(CONSTANTS.TOPICS.FORCE_SYNC));

  return getTopicPromises(donePromise, errorPromise);
}
1210304
public static void create( String baseName ,
                               File dataFolder ,
                               int blockCount ,
                               int blockSize ,
                               boolean forceSync ) throws DataStoreException
    {
        if (blockCount <= 0)
            throw new DataStoreException("Block count should be > 0");
        if (blockSize <= 0)
            throw new DataStoreException("Block size should be > 0");
        
        File atFile = new File(dataFolder,baseName+AbstractBlockBasedDataStore.ALLOCATION_TABLE_SUFFIX);
        File dataFile = new File(dataFolder,baseName+AbstractBlockBasedDataStore.DATA_FILE_SUFFIX);
        if (atFile.exists())
            throw new DataStoreException("Cannot create store filesystem : "+atFile.getAbsolutePath()+" already exists");
        if (dataFile.exists())
            throw new DataStoreException("Cannot create store filesystem : "+dataFile.getAbsolutePath()+" already exists");
        
        initAllocationTable(atFile,
                            blockCount,
                            blockSize,
                            forceSync);
        initDataFile(dataFile,
                     blockCount,
                     blockSize,
                     forceSync);
    }
757619
def write_report(self, force=False):
        '''
        
        '''
        path = self.title + '.html'
        value = self._template.format(
            title=self.title, body=self.body, sidebar=self.sidebar)
        write_file(path, value, force=force)
        plt.ion()
860592
public void write(ObjectWriter out, PersistedPropertyData propData) throws IOException
   {
      // write id
      out.writeInt(SerializationConstants.PERSISTED_PROPERTY_DATA);

      out.writeString(propData.getQPath().getAsString());
      out.writeString(propData.getIdentifier());

      if (propData.getParentIdentifier() != null)
      {
         out.writeByte(SerializationConstants.NOT_NULL_DATA);
         out.writeString(propData.getParentIdentifier());
      }
      else
         out.writeByte(SerializationConstants.NULL_DATA);

      out.writeInt(propData.getPersistedVersion());
      // -------------------

      out.writeInt(propData.getType());
      out.writeBoolean(propData.isMultiValued());
      out.writeLong(propData.getPersistedSize());

      List<ValueData> values = propData.getValues();
      if (values != null)
      {
         out.writeByte(SerializationConstants.NOT_NULL_DATA);
         int listSize = values.size();
         out.writeInt(listSize);
         PersistedValueDataWriter wr = new PersistedValueDataWriter();
         for (int i = 0; i < listSize; i++)
         {
            wr.write(out, (PersistedValueData)values.get(i));
         }
      }
      else
      {
         out.writeByte(SerializationConstants.NULL_DATA);
      }

   }
1318535
public void writeFile(String aFilePath, byte[] aData, boolean append) throws IOException
   {
      Object lock = retrieveLock(aFilePath);      
      synchronized (lock) 
      {
         IO.writeFile(aFilePath, aData,append);
      }
   
   }
1358271
@Override
    @FFDCIgnore({ IOException.class })
    public void writeFile(FileChannel fc) throws IOException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(tc, "writeFile: " + fc);
        }
        if (cannotWriteFC()) {
            // not file channel capable
            convertFile(fc);
            return;
        }
        // make sure the headers are written separately from the file buffer
        flushHeaders();
        WsByteBuffer fb = HttpDispatcher.getBufferManager().allocateFileChannelBuffer(fc);
        try {
            // TODO should adjust write timeout based on file size. Large files
            // can only be written so fast so a 1Gb file should have larger
            // timeout than a 100K file
            this.isc.sendResponseBody(new WsByteBuffer[] { fb });
            this.bytesWritten += fc.size();
        } catch (MessageSentException mse) {
            FFDCFilter.processException(mse, getClass().getName(),
                                        "writeFile", new Object[] { this, this.isc });
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(tc, "Invalid state, message-sent-exception received; " + this.isc);
            }
            this.error = new IOException("Invalid state");
            throw this.error;
        } catch (IOException ioe) {
            // no FFDC required
            this.error = ioe;
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Received exception during write: " + ioe);
            }
            throw ioe;
        } finally {
            fb.release();
        }
    }
594004
public synchronized void forceRun() throws MarkLogicSesameException {
        log.debug(String.valueOf(cache.size()));
        if( !cache.isEmpty()) {
            try {
                flush();
            } catch (RepositoryException e) {
                throw new MarkLogicSesameException("Could not flush write cache, encountered repository issue.",e);
            } catch (MalformedQueryException e) {
                throw new MarkLogicSesameException("Could not flush write cache, query was malformed.",e);
            } catch (UpdateExecutionException e) {
                throw new MarkLogicSesameException("Could not flush write cache, query update failed.",e);
            } catch (IOException e) {
                throw new MarkLogicSesameException("Could not flush write cache, encountered IO issue.",e);
            }
        }
    }
660904
private boolean forceLoad(PropertyData prop)
   {
      final List<ValueData> vals = prop.getValues();
      for (int i = 0; i < vals.size(); i++)
      {
         ValueData vd = vals.get(i);
         if (!vd.isByteArray())
         {
            // check if file is correct
            FilePersistedValueData fpvd = (FilePersistedValueData)vd;
            if (fpvd.getFile() == null)
            {
               if (fpvd instanceof StreamPersistedValueData && ((StreamPersistedValueData)fpvd).getUrl() != null)
                  continue;
               return true;
            }
            else if (!PrivilegedFileHelper.exists(fpvd.getFile()))// check if file exist
            {
               return true;
            }
         }
      }
      return false;
   }
1257475
protected long writeValue(File file, ValueData value) throws IOException
   {
      if (value.isByteArray())
      {
         return writeByteArrayValue(file, value);
      }
      else
      {
         return writeStreamedValue(file, value);
      }
   }