InputStream is = System.in;
try {
int count = 0;
while (count == 0) {
count = is.available();
}
byte[] b = new byte[count];
is.read(b);
String str = new String(b);
System.out.println(str);
File f = new File(str);
System.out.println(f.isDirectory());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
为什么f.isDirectory()会是false?
java string
------解决方案--------------------
f.isDirectory() : f是不是一个文件目录》
你的“F:/workspace/src"
目录存在么? 存在的话,应该会显示true的。
------解决方案--------------------
你的程序我改了下 你看是不是想这么干
Scanner scanner=new Scanner(System.in);
String is=scanner.nextLine();
// int count = 0;
//// while (count == 0) {
//// count = is.available();
//// }
// byte[] b = new byte[count];
// is.read(b);
// String str = new String(b);
System.out.println(is);