实际上我第一次使用formatter类写入java中的文件时,我的文件路径出错,错误序列错误!
以下是我尝试编写的代码:
package fileManipulation;
import java.io.FileNotFoundException;
import java.util.Formatter;
public class fileReading {
public static void main(String[] args) {
try{
Formatter Outfile=new Formatter("\F:\Users\User\Desktop\OOSD\Semester Two\Student.txt");
catch(FileNotFoundException fnfe)
{
System.out.println("Error in creating file!");
}
catch(SecurityException se)
{
System.out.println("User have permission to edit file!");
}
}
Outfile.format("%s NAme , %d Salary");
Outfile.close();
}
}