File tree Expand file tree Collapse file tree 2 files changed +24
-5
lines changed
main/java/org/fugerit/java/core/io
test/java/test/org/fugerit/java/core/io Expand file tree Collapse file tree 2 files changed +24
-5
lines changed Original file line number Diff line number Diff line change @@ -50,18 +50,17 @@ public static boolean isInTmpFolder( String tempFilePath ) throws IOException {
5050 }
5151
5252 public static boolean createFullFile ( File file ) throws IOException {
53- boolean created = true ;
53+ boolean created = Boolean . TRUE ;
5454 if ( file .exists () ) {
55- created = false ;
55+ return Boolean . FALSE ;
5656 } else {
5757 if ( file .isDirectory () ) {
58- created = file .mkdirs ();
58+ return file .mkdirs ();
5959 } else {
6060 file .getParentFile ().mkdirs ();
61- created = file .createNewFile ();
61+ return file .createNewFile ();
6262 }
6363 }
64- return created ;
6564 }
6665
6766 /*
Original file line number Diff line number Diff line change @@ -33,4 +33,24 @@ public void testNewFile() throws IOException {
3333 Assert .assertTrue ( FileIO .newFile ( baseDir , fileNameExists , Boolean .TRUE ).getPath ().endsWith ( fileNameExists ) );
3434 }
3535
36+
37+ @ Test
38+ public void testCreateFullFile () throws IOException {
39+ String baseDir0 = "target" ;
40+ String baseDir1 = "target/path/" ;
41+ String fileName = "not-exists.txt" ;
42+ String fileNameExists = "classes" ;
43+ File file0 = FileIO .newFile ( baseDir0 , fileName );
44+ File file1 = FileIO .newFile ( baseDir1 , fileName );
45+ File file2 = FileIO .newFile ( baseDir0 , fileNameExists );
46+ file0 .delete ();
47+ file1 .delete ();
48+ file1 .getParentFile ().delete ();
49+ file2 .delete ();
50+ Assert .assertTrue ( FileIO .createFullFile ( file0 ) );
51+ Assert .assertTrue ( FileIO .createFullFile ( file1 ) );
52+ Assert .assertFalse ( FileIO .createFullFile ( file0 ) );
53+ Assert .assertFalse ( FileIO .createFullFile ( file2 ) );
54+ }
55+
3656}
You can’t perform that action at this time.
0 commit comments