package st;import java.io.FileNotFoundException;
import java.io.IOException;public class TryTest5 {public static void main(String[] args) throws IOException {//正常情况readFile("c:\a.txt");//路径不对//readFile("d:\a.txt");//后缀不对//readFile("c:\a.tx");}public static void readFile(String fileName) throws FileNotFoundException, IOException {if (!dsWith(".txt")) {throw new IOException("文件后缀名称不对");}if (!fileName.equals("c:\a.txt")) {throw new FileNotFoundException("文件路径名不对");}System.out.println("路径没有问题,读取文件");}}
package st;import java.io.FileNotFoundException;
import java.io.IOException;public class TryTest5 {public static void main(String[] args) throws IOException {//正常情况//readFile("c:\a.txt");//文件后缀不对readFile("c:\a.tx");//文件路径不对//readFile("d:\a.txt");}public static void readFile(String fileName) throws FileNotFoundException, IOException {if (!dsWith(".txt")) {throw new IOException("文件后缀名称不对");}if (!fileName.equals("c:\a.txt")) {throw new FileNotFoundException("文件路径名不对");}System.out.println("路径没有问题,读取文件");}}
package st;import java.io.FileNotFoundException;
import java.io.IOException;public class TryTest5 {public static void main(String[] args) throws IOException {//正常情况//readFile("c:\a.txt");//文件后缀不对// readFile("c:\a.tx");//文件路径不对readFile("d:\a.txt");}public static void readFile(String fileName) throws FileNotFoundException, IOException {if (!dsWith(".txt")) {throw new IOException("文件后缀名称不对");}if (!fileName.equals("c:\a.txt")) {throw new FileNotFoundException("文件路径名不对");}System.out.println("路径没有问题,读取文件");}}
本文发布于:2024-02-01 07:02:27,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170674214734742.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |