在Java中,可以使用以下方式創建輸入流對象:
System.in
創建標準輸入流對象:InputStream inputStream = System.in;
File
對象創建文件輸入流對象:File file = new File("filename.txt");
InputStream inputStream = new FileInputStream(file);
URL
對象創建URL輸入流對象:URL url = new URL("https://example.com");
InputStream inputStream = url.openStream();
Socket
對象創建網絡輸入流對象:Socket socket = new Socket("localhost", 8080);
InputStream inputStream = socket.getInputStream();
請根據具體的需求選擇適合的方式創建輸入流對象。