Java args pass file as parameter

2

I am doing a graph work where I have to make a library and after generating the jar in the execution I need to inform two parameters that are txt files, the first one will be the input data in the second output. My doubt is how I do to pass two txts as args parameter?

    
asked by anonymous 26.11.2015 / 15:44

2 answers

1

Instead of trying to pass the files by parameter, pass the files path and instantiate with the class File in the application.

public static void main(string[] args){
    for(String arq : args){
        File file = new File(arq);
    }
}
    
26.11.2015 / 16:46
0
public  void passarArquivos( String ... paths ) { 

        File arquivo ;

        for (String caminho : paths) {

            arquivo = new File( caminho );

            System.out.println(" Nome :"+ arquivo.getName() );

        }

 }


 public static void main(String[] args) {

        SuaClass suaClass = new SuaClass();

        suaClass.passarArquivo("C:\arquivo1.txt" , "C:\arquivo2.txt" );
 }
    
26.11.2015 / 18:34