簡體   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