Which Java IO class is better to use for a simple shell interpreter? -


i new java io library, have trouble choosing right class purposes. write simple shell client file transferring server. client should understand 3 commands: list files in remote directory (optionally can take nested directory path argument), download specified file (with file path required argument) , end session (a separate command). concerned handling user's input @ moment. questions are:

  1. should read whole line of input, tokenize , logic, or better tokenize input comes , make immediate decisions based on it?
  2. what class should use tokenize input: scanner or streamtokenizer? or taking account commands simple use bufferedreader read line, split string "\\s+" pattern?

the questions may seem subjective in way want diminish confusion , understand specific use cases of io classes.

  1. considering commands basic, reading whole input , tokenizing require lot of efforts. better tokenize input , take decisions required.
  2. i think bufferedreader sufficient serve purpose here. make code easy. when working on taking input csv file , tokenizing display graph used same. logic parsing string goes below:-

      string splitby = ";"; // using csv file below used ";" splitter. can change per needs    bufferedreader br = new bufferedreader(new filereader("file.csv"));   string line = br.readline();   while((line = br.readline()) != null)   {        string[] b = line.split(splitby);        //take actions need perform   }   br.close(); 

hope answers question. let me know if more details required.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

java - Digest auth with Spring Security using javaconfig -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -