llama90 commented on code in PR #42115:
URL: https://github.com/apache/arrow/pull/42115#discussion_r1637339293


##########
java/tools/src/main/java/org/apache/arrow/tools/FileRoundtrip.java:
##########
@@ -52,13 +52,29 @@ public static void main(String[] args) {
     System.exit(new FileRoundtrip(System.err).run(args));
   }
 
-  private File validateFile(String type, String fileName) {
+  private File validateFile(String type, String fileName) throws IOException {
     if (fileName == null) {
       throw new IllegalArgumentException("missing " + type + " file 
parameter");
     }
     File f = new File(fileName);
-    if (!f.exists() || f.isDirectory()) {
-      throw new IllegalArgumentException(type + " file not found: " + 
f.getAbsolutePath());
+    if (type.equals("input")) {
+      if (!f.exists() || f.isDirectory()) {
+        throw new IllegalArgumentException(type + " file not found: " + 
f.getAbsolutePath());
+      }
+    } else if (type.equals("output")) {
+      File parentDir = f.getParentFile();
+      if (parentDir != null && !parentDir.exists()) {
+        if (!parentDir.mkdirs()) {
+          throw new IOException(
+              "Failed to create parent directory: " + 
parentDir.getAbsolutePath());
+        }
+      }
+      if (!f.exists()) {

Review Comment:
   Aha! You are right. We don't need to create the file in `validateFile`. This 
is because the `run` method executes `try (FileOutputStream fileOutputStream = 
new FileOutputStream(outFile);`.
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to