A queue for objects that are atomically and durably serialized to {@code file}.
969445
public static <T> ObjectQueue<T> create(QueueFile qf, Converter<T> converter) {
    return new FileObjectQueue<>(qf, converter);
  }
270248
public static void storeCache(Map<String, String> map, File file) {
        BufferedWriter bw = null;
        try {
            // Ensure that we the directory exists (maybe this should be done at
            // another place).
            file.getParentFile().mkdirs();
            bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file)));
            for (Entry<String, String> en : map.entrySet()) {
                bw.write(en.getValue());
                bw.write(' ');
                bw.write(en.getKey());
                bw.write('\n');
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            FileUtil.closeAndIgnoreExceptions(bw);
        }
    }
222888
public static byte[] toByteArray(File file) {
        FileInputStream is = null;
        try {
            is = new FileInputStream(file);
            return toByteArray(is);
        } catch (IOException e) {
            throw new RuntimeException(e);
        } finally {
            closeQuietly(is);
        }
    }
1259687
private void writeObject(java.io.ObjectOutputStream s)
            throws java.io.IOException {
        final java.io.ObjectOutputStream.PutField fields = s.putFields();
        final Object[] data;
        synchronized (this) {
            fields.put("capacityIncrement", capacityIncrement);
            fields.put("elementCount", elementCount);
            data = elementData.clone();
        }
        fields.put("elementData", data);
        s.writeFields();
    }
14860
public static <T extends SerializableObject> T deserialize(File file, Class<T> cls) throws IOException {
		FileInputStream stream = null;
		try {
			stream = new FileInputStream(file);
			DataInputStream in = new DataInputStream(stream);

			try {
				Constructor<T> constructor = cls.getDeclaredConstructor(DataInput.class);
				constructor.setAccessible(true);
				return constructor.newInstance(in);
			} catch (Exception e) {
				throw new IOException("Unable to instantiate class: " + cls, e);
			}
		} finally {
			Util.ensureClosed(stream);
		}
	}
508133
def _CopyFileObjectToTemporaryFile(self, file_object, temporary_file):
    
    file_object.seek(0, os.SEEK_SET)
    data = file_object.read(self._READ_BUFFER_SIZE)
    while data:
      temporary_file.write(data)
      data = file_object.read(self._READ_BUFFER_SIZE)
676946
public static void serializeObjectToFile(Object object, String filename) {
    FileOutputStream fos = null;
    ObjectOutputStream out = null;
    try {
      fos = new FileOutputStream(filename);
      out = new ObjectOutputStream(fos);
      out.writeObject(object);
      out.close();
    } catch(IOException ex) {
      ex.printStackTrace();
      System.exit(1);
    }    
  }
1204888
public static MappedByteBuffer map(File file) {
        N.checkArgNotNull(file);

        return map(file, MapMode.READ_ONLY);
    }
1319722
public static void writeObjectToFile(File file, Object object) throws IOException {
    FileOutputStream fs = new FileOutputStream(file);
    ObjectOutputStream os = new ObjectOutputStream(fs);
    os.writeObject(object);
    os.close();
  }
176922
private synchronized void writeObject(java.io.ObjectOutputStream stream)
			throws java.io.IOException
	{
		ThreadState tmp = this.threadState;
		this.threadStateSerilizationHashedId = serilizationCache.store(this.threadState);
		this.threadState = null;
		stream.defaultWriteObject();
		this.threadState = tmp;
	}
1159005
public static <T extends Serializable> File serializeToTempFile(T obj) throws IOException
        {
                File file = File.createTempFile(Serializer.class.getName().replace(".*\\.",""), null);
                file.deleteOnExit();
                serializeToFile(obj,file);
		return file;
        }
457563
function File(file) {
  this.cache = new Map();
  this.history = [];
  this.pattern = file.pattern;
  this.recurse = file.recurse;
  this.dirname = file.dirname;
  this.segment = file.segment;
  this.path = file.path;
  this.orig = file.path;
}
1206124
public static void serializeToDisk( File file, Object obj ) throws IOException {
        byte[] serializedObj = serialize(obj);
        try (RandomAccessFile raFile = new RandomAccessFile(file, "rw")) {
            raFile.write(serializedObj);
        }
    }
541297
public static void serialize(File file, SerializableObject object, @NonNull EncryptionKey encryptionKey) throws IOException {
		ByteArrayOutputStream bos = null;
		DataOutputStream dos = null;
		try {
			bos = new ByteArrayOutputStream();
			dos = new DataOutputStream(bos);
			object.writeExternal(dos);
			final byte[] unencryptedBytes = bos.toByteArray();
			final byte[] encryptedBytes = Encryptor.encrypt(encryptionKey, unencryptedBytes);
			Util.writeAtomically(file, encryptedBytes);
		} catch (Exception e) {
			throw new IOException(e);
		} finally {
			Util.ensureClosed(bos);
			Util.ensureClosed(dos);
		}
	}
492997
@Override
    public void send(final File file, final CallbackHandler handler)
    {
        log.info("Sending local file to collector: {}", file.getAbsolutePath());
        final long startTime = System.nanoTime();

        final AsyncCompletionHandler<Response> asyncCompletionHandler = new AsyncCompletionHandler<Response>()
        {
            @Override
            public Response onCompleted(final Response response)
            {
                activeRequests.decrementAndGet();

                if (response.getStatusCode() == 202) {
                    handler.onSuccess(file);
                }
                else {
                    handler.onError(new IOException(String.format("Received response %d: %s",
                                                                  response.getStatusCode(), response.getStatusText())), file);
                }

                sendTimer.update(System.nanoTime() - startTime, TimeUnit.NANOSECONDS);
                return response; // never read
            }

            @Override
            public void onThrowable(final Throwable t)
            {
                activeRequests.decrementAndGet();
                handler.onError(t, file);
            }
        };

        final HttpJob job = new HttpJob(client, file, asyncCompletionHandler);
        workers.offer(job);
    }
738560
private S getInputStreamForFile(File file) throws IOException {
        assert file != null : "File must be specified";
        return this.getInputStreamForRawStream(new FileInputStream(file));
    }
565134
def copy(self, src_fs, src_path, dst_fs, dst_path):
        # type: (FS, Text, FS, Text) -> None
        """"""
        if self.queue is None:
            # This should be the most performant for a single-thread
            copy_file_internal(src_fs, src_path, dst_fs, dst_path)
        else:
            src_file = src_fs.openbin(src_path, "r")
            try:
                dst_file = dst_fs.openbin(dst_path, "w")
            except Exception:
                src_file.close()
                raise
            task = _CopyTask(src_file, dst_file)
            self.queue.put(task)