public class ScriptCreator {
public static void main(String[] args) throws IOException {
#Choose the CSV file that I am importing the data from
String fName = "C:\\Users\\MyUser\\Downloads\\CurrentApplications (1).csv";
String thisLine;
int count = 0;
FileInputStream fis = new FileInputStream(fName);
DataInputStream myInput = new DataInputStream(fis);
int i = 0;
#Prints the List of names in the CSV file
while((thisLine = myInput.readLine()) != null){
String strar[] = thisLine.split(",");
Printer(strar[0]);
}
}
public static void Printer(String arg) throws IOException{
#Want to pull from the String strar[0] from above
#Says that it cannot be resolved to a variable
String name = arg;
String direc = "C:/Users/MyUser/Documents/";
String path = "C:/Users/MyUser/Documents";
Iterable<String> lines = Arrays.asList("LOGIN -acceptssl ServerName","N " + name + " " + direc ,"cd " + name,"import " + path + "*.ppf" + " true","scan", "publishassessase -aseapplication " + name,"removeassess *","del " + name);
Path file = Paths.get(name + ".txt");
Files.write(file, lines, Charset.forName("UTF-8"));
}
}
こんにちは皆さん、ありがとうございました。ありがとうございました。私は、CSVファイルから名前を取得し、それらの名前を取ってテキストファイルのカスタム出力を生成するJavaプログラムを作成しようとしています。私は、印刷されている名前を取得し、名前変数を設定することによってテキストファイルを生成するために使用できる変数を設定することが困難です。 また、CSVファイルに名前の量のスクリプトが作成されていることを確認するための助けが必要です。 Ex。 CSVの7つの名前で7つのカスタム.txtファイルが作成され、それぞれに適切な名前が付けられます。Javaでカスタムテキストファイルを生成
ご協力いただきありがとうございます。
編集:コードを動作させるために必要な修正に合わせてコードを更新しました。
あなたは私の好きな人の一人です。出来た!!私は上向きに投票しようとしましたが、私はそれについて十分な評判がありません。 – Dom
心配はいりません!お役に立てて嬉しいです :) – Daniel