system.setin
系统类setIn()方法 (System class setIn() method)
- setIn() method is available in java.lang package. - setIn()方法在java.lang包中可用。 
- setIn() method is used to assign again the standard input stream. - setIn()方法用于再次分配标准输入流。 
- setIn() method is redirected because it does not read the input from the editor. - setIn()方法被重定向,因为它不从编辑器读取输入。 
- setIn() method read the input from the standard input stream. - setIn()方法从标准输入流中读取输入。 
- setIn() method is a static method, it is accessible with the class name too. - setIn()方法是静态方法,也可以使用类名进行访问。 
- setIn() method may throw an exception while reading the input from the standard input stream: - 从标准输入流中读取输入时, setIn()方法可能会引发异常: - SecurityException: In this exception checkPermission() method does not allow reassigning of the latest standard input stream when security manager exists. - SecurityException:在此异常中,当存在安全管理器时,checkPermission()方法不允许重新分配最新的标准输入流。 
Syntax:
句法:
    public static void setIn(InputStream set_in);
Parameter(s):
参数:
- InputStream set_in – represents the latest standard input stream. - InputStream set_in –表示最新的标准输入流。 
Return value:
返回值:
The return type of this method is void, it does not return anything.
此方法的返回类型为void ,它不返回任何内容。
Example:
例:
// Java program to demonstrate the example of 
// setIn () method of System Class
import java.lang.*;
import java.io.*;
public class SetInMethod {
public static void main(String[] args) throws Exception {
// Display file in a specific manner
System.setIn(new FileInputStream("E://Programs//getProperties().doc"));
// Read the first character in the file
char read_first_char = (char) System.in.read();
// Display first character of the File
System.out.println(read_first_char);
}
}
Output
输出量
E:\Programs>javac SetInMethod.java
E:\Programs>java SetInMethod
J
翻译自: https://www.includehelp.com/java/system-class-setin-method-with-example.aspx
system.setin