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 파일에있는 이름의 양에 맞게 스크립트를 만드는 데 도움이 필요합니다. 전의. CSV의 7 개 이름은 7 개의 사용자 지정 .txt 파일을 만들고 각각은 적절한 이름을 사용합니다.자바에서 사용자 정의 텍스트 파일 생성
도움을 주시면 대단히 감사하겠습니다.
편집 : 코드를 수정하는 데 필요한 수정 작업과 일치하도록 코드를 업데이트했습니다.
지금 내 좋아하는 사람 중 한 명입니다. 그것은 일했다!! 나는 투표를하려했지만 그 점에 대해서는 충분히 높은 평판을 얻지 못했습니다. – Dom
걱정할 필요가 없습니다! 다행히 도울 수있어 :) – Daniel