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.pswp.cn/news/378769.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/378769.shtml
英文地址,請注明出處:http://en.pswp.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下可以 火狐下…