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"));
}
}
大家好,並且預先感謝您提供任何幫助,您可能會給我。我正在嘗試創建一個java程序,它將從CSV文件中提取名稱,並將這些名稱用於爲文本文件生成自定義輸出。我很難設置一個變量,我可以使用它來獲取正在打印的名稱,並使用它們通過設置名稱變量來生成文本文件。 我也需要一些幫助,以確保它爲CSV文件中的名稱量創建腳本的數量。防爆。 CSV中的7個名稱會生成7個自定義.txt文件,每個文件都有其適當的名稱。用java生成自定義文本文件
任何幫助,非常感謝!
編輯:我已更新我的代碼以匹配使代碼正常工作所需的更正。
你恰好是我現在最喜歡的人之一。有效!!我試圖投票,但我沒有足夠的聲譽。 – Dom
不用擔心!很高興我能幫上忙 :) – Daniel