Java FileDescriptor sync()方法与示例

FileDescriptor类sync()方法 (FileDescriptor Class sync() method)

  • sync() method is available in java.io package.

    sync()方法在java.io包中可用。

  • sync() method is used to synchronize all the system buffer with the underlying device.

    sync()方法用于将所有系统缓冲区与基础设备同步。

  • sync() method is a non-static method, it is accessible with the class object only and if we try to access the method with the class name then we will get an error.

    sync()方法是一种非静态方法,只能通过类对象访问,如果尝试使用类名称访问该方法,则会收到错误消息。

  • sync() method may throw an exception at the time of synchronizing.

    sync()方法在同步时可能会引发异常。

    SyncFailedException: This exception may throw when the buffer cannot be flushed or the system cannot be sure synchronization of all the buffers with the underlying device.

    SyncFailedException :当无法刷新缓冲区或系统无法确保所有缓冲区与基础设备同步时,可能引发此异常。

Syntax:

句法:

    public void sync();

Parameter(s):

参数:

  • It does not accept any parameter.

    它不接受任何参数。

Return value:

返回值:

The return type of the method is void, it returns nothing.

该方法的返回类型为void ,不返回任何内容。

Example:

例:

// Java program to demonstrate the example 
// of void sync() method of FileDescriptor
import java.io.*;
public class SyncOfFD {
public static void main(String[] args) throws Exception {
FileOutputStream os_stm = null;
try {
// Instantiates FileOutputStream 
os_stm = new FileOutputStream("D:\\includehelp.txt");
// By using getFD() method is to get
// the file descriptor
FileDescriptor file_des = os_stm.getFD();
// By using write() method is to
// write corresponding char 'A' to
// the output stream os_stm 
os_stm.write(65);
// By using sync() method is to
// sync the data to the file
file_des.sync();
System.out.println("Sync() executed ");
} catch (Exception ex) {
System.out.println(ex.toString());
} finally {
// with the help of this block is to
// free all necessary resources linked
// with the stream
if (os_stm != null) {
os_stm.close();
}
}
}
}

Output

输出量

Sync() executed

翻译自: https://www.includehelp.com/java/filedescriptor-sync-method-with-example.aspx

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/378769.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

windows 7资源管理器崩溃解决方法

最近被频繁的资源管理器explorer崩溃搞得几乎生活不能处理,一打开带有视频的文件夹,就explorer崩溃,要疯了。 日志中含有mpc_mtcontrol.dll 查来查去,没有一个确定的答案,baidu,google都没用,最…

03-对图像进行数值计算和加权融合

数值计算 import cv2img_1 cv2.imread(E:\Jupyter_workspace\study\data/beyond.png) img_2 cv2.imread(E:\Jupyter_workspace\study\data/water2.png)img_1_1 img_1 10 img_1[:2,:,0]#输出前两行就行 img_1_1[:2,:,0]#[h,w,c] img_2[:2,:,0]#[h,w,c](img_1 img_2)[:2,:,…

SQL Server存储过程(procedure)应用

用户反映,系统操作日志会使用数据库快速增大,情况可参考下图, 问题分析,整个系统每个页面,都有写记录用户操作代码,修改或禁用这个代码,看来是不可能的。 在原有系统参数表添加一个选项&#xf…

Opencv一维直方图的绘制

下面是我参考《opencv3编程入门》写的绘制一维直方图的代码 using namespace cv; using namespace std; #define byte uchar #define TYEPE_GRAY 0 #define TYEPE_RGB 1 /*--------------------------绘制RGB三色一维直方图-------------------------------------*/ Mat My_R…

Java类class forName()方法及示例

类类forName()方法 (Class class forName() method) forName() method is available in java.lang package. forName()方法在java.lang包中可用。 forName() method is used to return the class object for the Class with the given class_name. forName()方法用于返回具有给…

04-图像的阈值操作

对图像的阈值操作 import cv2 import matplotlib.pyplot as pltimg cv2.imread(E:/Jupyter_workspace/study/data/cat.png,1) ret, thresh1 cv2.threshold(img,127,255,cv2.THRESH_BINARY) ret, thresh2 cv2.threshold(img,127,255,cv2.THRESH_BINARY_INV) ret, thresh3 c…

java虚拟机内存监控_深入理解JVM虚拟机9:JVM监控工具与诊断实践

本文转自:https://juejin.im/post/59e6c1f26fb9a0451c397a8c本系列文章将整理到我在GitHub上的《Java面试指南》仓库,更多精彩内容请到我的仓库里查看https://github.com/h3pl/Java-Tutorial喜欢的话麻烦点下Star哈文章将同步到我的个人博客:…

详解:数据库名、实例名、ORACLE_SID、数据库域名、全局数据库名、服务名

数据库名、实例名、数据库域名、全局数据库名、服务名,这是几个令很多初学者容易混淆的概念。相信很多初学者都与我一样被标题上这些个概念搞得一头雾水。我们现在就来把它们弄个明白。 一、数据库名什么是数据库名?数据库名就是一个数据库的标识&#…

颜色缩减 -利用指针、迭代器、动态地址实现访问像素

为什么要使用颜色缩减 在对单通道图像进行处理时,像素的可能值为256个,但处理多通道时,像素的处理就会相当麻烦,其实用这些颜色中具有代表性的一小部分就可以达到同样的效果,所以颜色空间缩减就可以派上用场了。一个信…

setlenient_Java日历setLenient()方法与示例

setlenient日历类setLenient()方法 (Calendar Class setLenient() method) setLenient() method is available in java.util package. setLenient()方法在java.util包中可用。 setLenient() method is used to set or unset lenient status of date or time interpretations. s…

PowerShell_9_零基础自学课程_9_高级主题:静态类和类的操作

哈哈,昨天弄了个ubuntu 11.10在虚拟机上运行,发现11.10界面非常绚丽,但是其需要的系统资源非常多,我虚拟机设定内存为512M,1个CPU4个核心, 进入以后发现根本动不了,因此今天我就下载了一个Fedor…

05-图像的平滑处理(不同的滤波操作)

对图像进行平滑处理实则就是对图像进行滤波操作罢了 每张图片都有若干个像素点所构成,滤波操作上就是将照片上的某些部分像素点进行修改从而达到平滑的效果 先展示一下原图 import cv2 img cv2.imread(E:\Jupyter_workspace\study\data/test1.png)cv2.imshow(te…

js删除mysql记录_(DELETEUPDATE)修改、删除数据记录_MySQL

有时,希望除去某些记录或更改它们的内容。DELETE 和 UPDATE 语句令我们能做到这一点。用update修改记录UPDATE tbl_name SET 要更改的列WHERE 要更新的记录这里的 WHERE 子句是可选的,因此如果不指定的话,表中的每个记录都被更新。例如&#…

C++设计模式之Abstract Factory模式

一、功能   提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类。 二、结构图类厂最基本的结构示意图如下: 在实际应用中,类厂模式可以扩充到很复杂的情况,如下图所示: 三、优缺点 优点&#xff1…

数字图像处理小练习存档1

小练习的题目: 1、读取一张图,分解RGB三个通道 /************练习1**********************/ int main() {Mat img1 imread("D:\\opencv_picture_test\\miku2.jpg",2|4); //灰度图if (img1.empty()){printf("Could not find the imag…

UIImage 压缩

1.改变图片大小 -(UIImage*)imageWithImage:(UIImage*)image scaledToSize:(CGSize)newSize {// Create a graphics image contextUIGraphicsBeginImageContext(newSize);// Tell the old image to draw in this new context, with the desired// new size[image drawInRect:CG…

06-对图像进行腐蚀操作

形态学中的腐蚀操作一般处理的图像数据为二值的 cv2.erode(img,kernel,iterations 1) kernel表示拿多大的卷积核去腐蚀 iterations表示迭代次数 可以将一些带有毛毛的图像去毛毛化 原图 import cv2 import numpy as npdef show_photo(name,picture):cv2.imshow(name,picture)…

Java BufferedReader skip()方法与示例

BufferedReader类skip()方法 (BufferedReader Class skip() method) skip() method is available in java.io package. skip()方法在java.io包中可用。 skip() method is used to skip the given number of bytes of characters (n_bytes_of_char) from this BufferedReader. s…

mysql gtid binlog_MySQL之-四步实现BinLog Replication升级为GTIDs Replication的代码实例

1、将Master和Slave服务器都设置为read-onlymysql>SET global.read_onlyON;2、将Master与Slave服务器都停下来service mysql stop3、开启GTIDs开启GTIDs需要在master和slave服务器上都配置gtid-mode,log-bin,log-slave-updates,enforce-gtid-consistency(在MySQL 5.6.9之前是…

【记】琐碎

1.GIF载入问题:http://www.cnblogs.com/Lewis/archive/2011/01/17/1937066.html 2.正则分段数字: "12345678945612456".replace(new RegExp((\\d)(?(\\d{3})$),ig),"$1,") 其中用到了正则的后则判断? 3.给legend设定宽度 发现IE下可以 火狐下…