繁体   English   中英

如何使用jcreator制作复制粘贴脚本?

[英]how to make a copy-paste script with jcreator?

您能为我提供Java编码方面的帮助吗,所以我可以使用命令提示符复制单个文件。

因此,我想从Windows的命令提示符下运行Java文件,例如“ java“我的Java脚本”“我的文件目标”“,并在相同目录下复制我的”我的文件目标“,而无需替换旧文件。

请帮我?

我带着这个出来

import java.io.*;
class ReadWrite {
    public static void main(String args[]) throws IOException {
        FileInputStream fis = new FileInputStream(args[0]);
        FileOutputStream fos = new FileOutputStream("output.txt");
        int n;
        if(args.length != 1)
            throw (new RuntimeException("Usage : java ReadWrite <filetoread> <filetowrite>"));
        while((n=fis.read()) >= 0)
            fos.write(n);
    }
}

但是文件的副本名为output.txt,如果我想选择自己的输出名称,你们可以帮助我进行编码吗? 如果我在命令提示符下键入“ java ReadWrite input.txt(这是我想要的输出名称)”

这里真的需要帮助...

import java.util.Scanner;

public class program_23{ // start of class

    public static void main(String []args){  // start of main function.

        Scanner input = new Scanner (System.in);

        // decleration  ang initialization of variables
        String name = " ";
        int age  = 0;
        int no_of_hour_work = 0;
        double daily_rate = 0.0;

        // get user input
        System.out.print("Employee Name: ");
        name = input.nextLine();

        System.out.print("Employee Age: ");
        age = input.nextInt();

        System.out.print("No of hour(s) work: ");
        no_of_hour_work = input.nextInt();

        // compute for daily rate
        daily_rate = no_of_hour_work * 95.75;

        // display the daily rate
        System.out.print("Dialy rate:"+ daily_rate);

    }// end of main

}// end of class

伪代码:

input = open input stream for file1
output = open output stream for file 2
while (input.read() has more bytes):
    write byte to output stream
close(input, output)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM