I am new to java and moving my codes since last two years from VB to java using netbeans 8 . Now i want to write loop acumalted data to file and last to save produced file to specific place using FlieChooser below is my code but i can't see any file in My Desktop when I wrote name in doilog and press enter :
public void SaveToFile() throws IOException {
try (Writer writer = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("test.txt"), "utf-8"))) {
int i=0;
String Data[]=new String[10];
while( i<10 ){
writer.write("Student No :" + i);
Data[i]= "Student No :" + i;
++i;
}
}
int userSelection = db.showSaveDialog(this);
if (userSelection == JFileChooser.APPROVE_OPTION) {
File fileToSave = db.getCurrentDirectory();
String path = fileToSave.getAbsolutePath();
path = path.replace("\\", File.separator);
System.out.println("Save as file: " + path);
}
}