源码:
import java.io.*;
class inread{
public static void mian(String args[])
{
FileInputStream fis = new FileInputStream("c:\s.txt");
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
String s = br.readLine();
System.out.println(s);
br.close();
}
}
错在哪啊
--------------------Configuration: <Default>--------------------
C:\inread.java:5: illegal escape character
FileInputStream fis = new FileInputStream("c:\s.txt");
^
1 errorProcess completed.
import java.io.*;
class inread{
public static void mian(String args[])
{
FileInputStream fis = new FileInputStream("c:\s.txt");
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);
String s = br.readLine();
System.out.println(s);
br.close();
}
}
错在哪啊
--------------------Configuration: <Default>--------------------
C:\inread.java:5: illegal escape character
FileInputStream fis = new FileInputStream("c:\s.txt");
^
1 errorProcess completed.
解决方案 »
- 知道接口名如何得到他所有的实现类的名?
- 问个菜鸟的问题呵呵
- 测试ThreadLocal类在多线程下的运行怎么看不懂了,为什么新建一个线程initialValue()方法就被调用一次?不是仅仅只调用一次的吗?
- 我的JSP页面怎么显示不了图片呀~
- (高手請進)nio是非阻滯的,但是不是能同時處理多個請求呢?
- 请问打开Zip文件出现异常ZipException,提示无法打开zip文件,该如何解决?
- 请问哪有JDK下载,马上结贴!谢谢!
- 生成PDF报表的问题现在就剩下这一个了,大家帮帮忙,救救兄弟我啊
- JAVA初学者
- 新手求教:java程序不能运行,如何设置
- 100分,请问现在公司收违约金的现象普遍吗?如果收的话,大概是多少呢?
- 请教大侠struts程序中的数据访问层应该怎么写啊?谢谢!
应该是:
FileInputStream fis = new FileInputStream("c:\\s.txt");
或者
FileInputStream fis = new FileInputStream("c:/s.txt");
--------------------Configuration: <Default>--------------------
C:\inread.java:5: unreported exception java.io.FileNotFoundException; must be caught or declared to be thrown
FileInputStream fis = new FileInputStream("c:\\s.txt");
^
C:\inread.java:8: unreported exception java.io.IOException; must be caught or declared to be thrown
String s = br.readLine();
^
C:\inread.java:10: unreported exception java.io.IOException; must be caught or declared to be thrown
br.close();
^
3 errors
在你的方法后面加个 throws Exception
如
public static void main(String args[]) throws Exception
{}