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