import [Link].
*;
public class FileFolderOperations {
public static void main(String[] args) {
// Step 1: Create a folder named TestFolder
File folder = new File("TestFolder");
if (![Link]()) {
if ([Link]()) {
[Link]("Folder 'TestFolder' created successfully.");
} else {
[Link]("Failed to create folder.");
return;
}
}
// Step 2: Create a file named [Link] inside TestFolder
File file = new File("TestFolder/[Link]");
try {
if ([Link]()) {
[Link]("File '[Link]' created successfully.");
} else {
[Link]("File already exists.");
}
// Step 3: Write content into [Link]
FileWriter writer = new FileWriter(file);
[Link]("Hello, this is a test file.");
[Link]();
[Link]("Content written to '[Link]'.");
// Step 4: Read the content from [Link]
BufferedReader reader = new BufferedReader(new FileReader(file));
String line;
[Link]("Reading content from '[Link]':");
while ((line = [Link]()) != null) {
// Step 5: Print the content on the console
[Link](line);
}
[Link]();
// Step 6: Delete the file [Link]
if ([Link]()) {
[Link]("File '[Link]' deleted successfully.");
} else {
[Link]("Failed to delete '[Link]'.");
}
// Step 7: Delete the folder TestFolder after ensuring it is empty
if ([Link]()) {
[Link]("Folder 'TestFolder' deleted successfully.");
} else {
[Link]("Failed to delete 'TestFolder'. Make sure
it's empty.");
}
} catch (IOException e) {
[Link]("An error occurred: " + [Link]());
}
}
}
// Step 1: Create an interface Interface1 with a method methodA
interface Interface1 {
void methodA();
}
// Step 2: Create another interface Interface2 with a method methodB
interface Interface2 {
void methodB();
}
// Step 3: Create a class MultipleInheritanceDemo that implements both
interfaces
class MultipleInheritanceDemo implements Interface1, Interface2 {
// Step 4: Provide implementations for methodA and methodB
public void methodA() {
[Link]("MethodA from Interface1 implemented.");
}
public void methodB() {
[Link]("MethodB from Interface2 implemented.");
}
// Step 5: Create a main method to instantiate MultipleInheritanceDemo
public static void main(String[] args) {
MultipleInheritanceDemo obj = new MultipleInheritanceDemo();
[Link](); // Calling methodA
[Link](); // Calling methodB
}
}