Here you can find the source of getInputStream(String[] args)
Parameter | Description |
---|---|
args | command line args given to the program |
public static InputStream getInputStream(String[] args)
//package com.java2s; //License from project: LGPL import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.InputStream; public class Main { /**/*from w ww . ja va2 s.c om*/ * Searches the command line args for -f path_to_file. If it is present, it returns a {@link java.io.FileInputStream}. * @param args command line args given to the program * @return a {@link java.io.FileInputStream} or {@link System.in}, respectively */ public static InputStream getInputStream(String[] args) { for (int i = 0; i < args.length - 1; i++) { if ("-f".equals(args[i])) { File f = new File(args[i + 1]); if (f.exists() && f.isFile()) try { return new FileInputStream(f); } catch (FileNotFoundException e) { System.err.println("Something went horribly wrong!"); e.printStackTrace(); } } } return System.in; } }