Home > Back-end >  Questions about the JavaEE file reading and writing
Questions about the JavaEE file reading and writing

Time:09-21

Package company.

import java.io.File;
Import the Java. IO. IOException;

Public class FileTest {
Public static void main (String [] args) {
The File File=new File (" D: \ \ TGG text ");
If (the file. The exists ()) {
File. The delete ();
System. The out. Println (" the file has been deleted ");
} else {
Try {
File. CreateNewFile ();
System. The out. Println (" file has been created ");
} the catch (IOException e) {
e.printStackTrace();
}
}
}
}
when I set the TXT file format, why the computers will be found to open it? File size also show 0 KB,,

CodePudding user response:

You just create a file, there is no file is written to the information, so, of course, is an empty file is 0 bytes

CodePudding user response:

Can't open, you use notepad to open the right-click,
Size is zero, because didn't write anything,
Code logic, also do not conform to the common sense,

CodePudding user response:

Why the suffix is text, custom

CodePudding user response:

refer to the building of small er chenchen reply:
when I set the TXT file format, why will find on the computer can't open it? File size also show 0 KB,,


First suffix is TXT TXT file format you here suffix is text, no text in computer related application can open the file, so will show doesn't open,
Second and said several of the above, the file you just created, but the file and there was no any information content so that zero bytes,

CodePudding user response:

No written information byte 0, the file suffix is TXT?
  • Related