关于文件的读写,急!!! filename = "E:\\1.txt"; 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Sam1983(Sam Lau):对"\"是转义字符,要得到字符"\"要用"\\" 帮你搞定:把你的代码改为下面的代码:import java.io.*;class ShowFile{ public static void main(String args[])throws IOException { int i; String filename; filename = "E:\\1.txt"; FileInputStream fin; try{ fin = new FileInputStream(filename); } catch(FileNotFoundException e){ System.out.println("File Not Found"); return; } do{ i = fin.read(); if(i != -1) System.out.print((char) i); }while(i != -1); fin.close(); }}e盘目录建1.txt 1.txt写点东西就可以编译出来了 import java.io.*;class ShowFile{ public static void main(String args[])throws IOException { int i; String filename; // filename = "E:\1.txt"; filename = "E:\\1.txt"; FileInputStream fin; try{ fin = new FileInputStream(filename); } catch(FileNotFoundException e){ System.out.println("File Not Found"); return; }catch(ArrayIndexOutOfBoundsException e){ System.out.println("Usage: ShowFile File"); return; } do{ i = fin.read(); if(i != -1) System.out.print((char) i); }while(i != -1); fin.close(); } Eclipse: class file editor: source not found 真的需要逻辑思维 修女再出水 如果将文件流转化为ByteArrayInputStream 求助两个小程序! 写了一个背包问题的算法,请斧正! java /usr/test 出错 求连VFP数据的连法!有哪位大哥晓得啊! 求教--用“*”打印菱形 怎么来在J2SE应用程序中做一个超链接,点一下就可以边接到我们的网站上去? 俄罗斯方块的源码~~~过来看一下 菜鸟简单问题
"\"是转义字符,要得到字符"\"要用"\\"
import java.io.*;
class ShowFile{
public static void main(String args[])throws IOException
{
int i;
String filename;
filename = "E:\\1.txt";
FileInputStream fin;
try{
fin = new FileInputStream(filename);
}
catch(FileNotFoundException e){
System.out.println("File Not Found");
return;
}
do{
i = fin.read();
if(i != -1) System.out.print((char) i);
}while(i != -1);
fin.close();
}
}e盘目录建1.txt 1.txt写点东西就可以编译出来了
class ShowFile{
public static void main(String args[])throws IOException
{
int i;
String filename;
// filename = "E:\1.txt";
filename = "E:\\1.txt";
FileInputStream fin;
try{
fin = new FileInputStream(filename);
} catch(FileNotFoundException e){
System.out.println("File Not Found");
return;
}catch(ArrayIndexOutOfBoundsException e){
System.out.println("Usage: ShowFile File");
return;
}
do{
i = fin.read();
if(i != -1) System.out.print((char) i);
}while(i != -1);
fin.close();
}