Passing parameters at run time

Source: Internet
Author: User

Someone posted to ask the following program why the operation will be wrong?

The method Cypher (InputStream, OutputStream) in the type Myencodertext are not applicable for the arguments (Fileinputstrea M, FileOutputStream)
package package1;import java.io.*;p ublic class myencodertext {     public static void main (String[] args)  throws Exception {         String path0 = args[0];         String path1 = args[1];         Fileinputstream in = new fileinputstream (Path0);         fileoutputstream out = new fileoutputstream (path1);         cypher (in, out);          System.out.println ("End");         out.close ();     }     private static void cypher (Inputstream inp, outputstream  oup)             throws exception {        int  len = -1;        system.out.println ("0:  "  + len);        while  ((Len = inp.read ())  != -1)  {             System.out.println ("1: "  + len);             oup.write (len);// ^ 102 ^ 91             system.out.println ("2: "  + len);         }        system.out.println ("3: "  + oup);     }}

Then, I tried it, as if there was no problem?

It was suggested that he change the parameters of the Cypher method (FileInputStream INP, FileOutputStream OUP),

That's the end of the question. Bored.


and the Oup.write (len^ 102 ^ 91);

I was starting to think of something like a binary shift that would improve the efficiency of things like this,

The result is not at all! It would be a waste of time to annotate it to really perform the operation of copying files.


But this program reminds me of the issue of "passing parameters at runtime",

Wrote a small program:

public class Testargs {public static void main (string[] args) {String Arg1 = args[0];        String Arg2 = args[1];                String Arg3 = args[2];        System.out.println (ARG1);        System.out.println (ARG2);    System.out.println (ARG3); }}


In a CMD small black window or eclipse, as long as the parameters passed are separated by a space,

You can pass parameters to the program.

For example: Java Testargs A B C.

Eclipse is run configurations ... The window will not pass.

Passing parameters at run time

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.