stringreader_Java StringReader skip()方法與示例

stringreader

StringReader類skip()方法 (StringReader Class skip() method)

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

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

  • skip() method is used to skip the given number of characters in the stream.

    skip()方法用于跳過流中給定數量的字符。

  • skip() 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.

    skip()方法是一種非靜態方法,只能通過類對象訪問,如果嘗試使用類名稱訪問該方法,則會收到錯誤消息。

  • skip() method may throw an exception at the time of skipping the number of characters.

    skip()方法在跳過字符數時可能會引發異常。

    IOException: This exception may throw when getting any input/output error while performing.

    IOException :在執行過程中遇到任何輸入/輸出錯誤時,可能引發此異常。

Syntax:

句法:

    public long skip(long number);

Parameter(s):

參數:

  • long number – represents the number of characters to skip.

    長數字 -表示要跳過的字符數。

Return value:

返回值:

The return type of the method is long, it returns the exact number of characters skipped.

該方法的返回類型為long ,它返回跳過的確切字符數。

Example:

例:

// Java program to demonstrate the example 
// of long skip(long number) method of StringReader
import java.io.*;
public class SkipOfSR {
public static void main(String[] args) throws Exception {
StringReader str_r = null;
try {
// Instantiates StringReader
str_r = new StringReader("Java World");
// Loop to read until available
// bytes left
for (int val = 0; val <= 4; ++val) {
// Read corresponding char value
char ch = (char) str_r.read();
// Display value of ch
System.out.println("ch: " + ch + " ");
// By using skip() method is
// to skip 1 bytes of data
// from str_r	    
long skip = str_r.skip(1);
System.out.println("str_r.skip(1): " + skip);
}
} 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 (str_r != null) {
str_r.close();
}
}
}
}

Output

輸出量

ch: J 
str_r.skip(1): 1
ch: v 
str_r.skip(1): 1
ch:   
str_r.skip(1): 1
ch: o 
str_r.skip(1): 1
ch: l 
str_r.skip(1): 1

翻譯自: https://www.includehelp.com/java/stringreader-skip-method-with-example.aspx

stringreader

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/541344.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/541344.shtml
英文地址,請注明出處:http://en.pswp.cn/news/541344.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

NFS部署及優化(一)

NFS部署及優化&#xff08;一&#xff09;一、NFS的基本概念NFS network file system 網絡文件系統必然通過網絡通信來實現文件的訪問和寫入&#xff0c;所以做這個實驗的話最好有兩臺虛擬機配置:A&#xff1a;一個192.169.50.201為server端B&#xff1a;一個192.169.50.200為…

oracle 11g跳過壞塊,oracle 使用Dbms_Repair跳過壞塊

原博文&#xff1a;http://blog.chinaunix.net/uid-77311-id-3051382.html使用Dbms_Repair跳過壞塊步驟1:表tb_test中有壞塊(模擬壞塊同方法1)SQL> select count(1) from hxl.tb_test;select count(1) from hxl.tb_test*ERROR at line 1:ORA-01578: ORACLE data block corru…

strictmath_Java StrictMath nextUp()方法與示例

strictmathStrictMath類nextUp()方法 (StrictMath Class nextUp() method) Syntax: 句法&#xff1a; public static float nextUp(float fl);public static double nextUp(double do);nextUp() method is available in java.lang package. nextUp()方法在java.lang包中可用。…

并發數據結構-1.1 并發的數據結構的設計

原文鏈接&#xff0c;譯文鏈接&#xff0c;譯者&#xff1a;董明鑫&#xff0c;校對&#xff1a;周可人 隨著多個處理器共享同一內存的機器在商業上的廣泛使用&#xff0c;并發編程的藝術也產生了巨大的變化。當前的趨勢向著低功耗芯片級多線程&#xff08;CMT&#xff09;發展…

printstream_Java PrintStream close()方法與示例

printstreamPrintStream類close()方法 (PrintStream Class close() method) close() method is available in java.io package. close()方法在java.io包中可用。 close() method is used to close the underlying output stream. close()方法用于關閉基礎輸出流。 close() meth…

oracle底層執行順序,select語句結構與執行順序-Oracle

select語句結構與執行順序select語句的結構與執行順序&#xff0c;下面的序號代表執行順序8 SELECT (9)DISTINCT11 1 ROM 3   JOIN 2   ON 4 WHERE 5 GROUP BY 6 WITH {CUBE | ROLLUP}7 HAVING 10 ORDER BY 補…

HDU 4923 Room and Moor(瞎搞題)

瞎搞題啊。找出1 1 0 0這樣的序列&#xff0c;然后存起來&#xff0c;這樣的情況下最好的選擇是1的個數除以這段的總和。然后從前向后掃一遍。變掃邊進行合并。每次合并。合并的是他的前驅。這樣到最后從t-1找出的那條鏈就是最后滿足條件的數的大小。Room and Moor Time Limit:…

java define_Java Long類的define()方法與示例

java define長類解碼()方法 (Long class decode() method) decode() method is available in java.lang package. 在java.lang包中提供了define ()方法 。 decode() method is used to decode the given String value into a Long value. encode()方法用于將給定的String值解碼…

linux修改文件用戶組,linux命令 修改文件、文件夾所屬用戶、用戶組

最近學習hadoop&#xff0c;在替換配置文件的時候&#xff0c;發現老是報錯&#xff0c;沒有權限替換。我們知道如何改變文件的用戶組與擁有者了&#xff0c;那么&#xff0c;什么時候要使用chown或chgrp呢&#xff1f;或許你會覺得奇怪吧&#xff1f;是的&#xff0c;確實有時…

Kotlin 開篇

Kotlin 是一個基于 JVM 的新的編程語言&#xff0c;由 JetBrains 開發官網地址&#xff1a;http://kotlinlang.org。JetBrains&#xff0c;作為目前廣受歡迎的 Java IDE IntelliJ 的提供商&#xff0c;在 Apache 許可下已經開源其Kotlin 編程語言。開源地址&#xff1a;https:/…

inputstream示例_Java InputStream close()方法與示例

inputstream示例InputStream類close()方法 (InputStream Class close() method) close() method is available in java.io package. close()方法在java.io包中可用。 close() method is used to close this InputStream and free all system resources linked with this stream…

linux下的文件系統,Linux根文件系統(“/”文件系統)下的目錄介紹

Linux下的文件存儲與Windows完全不同&#xff0c;Windows將系統文件存儲在系統盤(比如說C:\下)Linux根本沒有盤符到概念只有一個根文件系/&#xff0c;各個磁盤分區掛載在/media/下(或者/mnt/下)/下到如/etc,/proc,/bin,/dev,lib等很是讓用慣了Windows的用戶不解&#xff0c;下…

greenlet 詳解

greenlet初體驗回到頂部Greenlet是python的一個C擴展&#xff0c;來源于Stackless python&#xff0c;旨在提供可自行調度的‘微線程’&#xff0c; 即協程。generator實現的協程在yield value時只能將value返回給調用者(caller)。 而在greenlet中&#xff0c;target.switch&am…

Java Calendar toString()方法與示例

日歷類toString()方法 (Calendar Class toString() method) toString() method is available in java.util package. toString()方法在java.util包中可用。 toString() method is used to string denotations of the calendar object. toString()方法用于對日歷對象的符號進行字…

linux虛擬機怎么看var文件,一種獲取Linux虛擬機內部日志的方法

一種獲取Linux虛擬機內部日志的方法【技術領域】[0001]本發明涉及云計算管理技術領域&#xff0c;特別是指一種獲取Linux虛擬機內部日志的方法。【背景技術】[0002]在云計算環境下&#xff0c;虛擬機被廣泛使用&#xff0c;對于虛擬機的維護要求越來越高&#xff0c;當虛擬機出…

詳細圖解mongodb 3.4.1 win7x64安裝

原文&#xff1a;http://www.cnblogs.com/yucongblog/p/6895983.html 詳細圖解&#xff0c;記錄 win7 64 安裝mongo數據庫的過程。安裝的版本是 MongoDB-win32-x86_64-2008plus-ssl-3.4.1-signed。 我下載的源文件&#xff1a;mongodb-win32-x86_64-2008plus-ssl-3.4.1-signed我…

java calendar_Java Calendar complete()方法與示例

java calendarCalendar類的complete()方法 (Calendar Class complete() method) complete() method is available in java.util package. complete()方法在java.util包中可用。 complete() method is used to fills in any non-set fields in the calendar fields. complete()方…

LXD 2.0 系列(十二):調試,及給 LXD 做貢獻

介紹 終于要結束了&#xff01;這個大約一年前開始的這系列文章的最后一篇博文。 LXD 入門安裝與配置你的第一個 LXD 容器資源控制鏡像管理遠程主機及容器遷移LXD 中的 DockerLXD 中的 LXD實時遷移LXD 和 JujuLXD 和 OpenStack調試&#xff0c;及給 LXD 做貢獻如果你從一開始就…

linux用ping命令測試網速,linux下面使用命令測試網速

大家都知道在speedtest是市面上最準確最全面的測速工具&#xff0c;但在linux命令行不能直接使用&#xff0c;所以我們就借助腳本調用speedtest的接口來利用他測試網速。1.下載speedtest-cli腳本&#xff1a;下載地址&#xff1a;https://raw.githubusercontent.com/sivel/spee…

Java ArrayList isEmpty()方法與示例

ArrayList類isEmpty()方法 (ArrayList Class isEmpty() method) isEmpty() method is available in java.util package. isEmpty()方法在java.util包中可用。 isEmpty() method is used to check whether this Arraylist is "empty" or "not empty". isEmp…