public class FlashStorage {
public static void main(String[] args) {
String flashDrivePath = "E:/"; // Replace with the actual path
String fileName = "myFile.txt";
File file = new File(flashDrivePath + fileName);
try {
// Write to file
FileWriter fw = new FileWriter(file);
BufferedWriter bw = new BufferedWriter(fw);
bw.write("Hello, Flash Storage!");
bw.close();
// Read from file
FileReader fr = new FileReader(file);
BufferedReader br = new BufferedReader(fr);
String line = br.readLine();
System.out.println("Data read: " + line);
br.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
No comments:
Post a Comment