Reputation: 1
Every time I create a file, I want it to do it inside a new folder with files name.
public void convertLocalSwaggerToAsciiDoc() throws IOException {
File folder = new File("C:\\Users\\jeff\\Desktop\\apidocs\\apidocs\\SwaggerJSON");
File[] listOfFiles = folder.listFiles(); //Makes an array of all the files
int index, length = lengthOfFiles(listOfFiles); //lengthOfFiles counts number of files inside the folder
for (index = 0; index < length ; index++) {
Swagger2MarkupConverter.from(listOfFiles[index].getPath()).build().intoFolder("src/docs/asciidoc/generated/conversion");
}
}
Upvotes: 0
Views: 94
Reputation: 2466
If i'm reading your question/statement correctly it looks like you want to create different folders.
In Java, this can be achieved by creating an instance of a File-
File file = new File("path to new folder");
And then calling-
file.mkdir();
to achieve the creation of a new Directory.
** Edit **
Iteratively, do something like this-
for (each file in the list) {
File folder = new File(path to parent folder + file.getName())
folder.mkdir();
File file = new File(folder.getPath() + currentFileName + currentFileExtension);
}
Upvotes: 2