A.Increasing the size of a logical volume also increases the size of the file system
B.Reducing the size of a logical volume requires reducing the size of the file system first
C.Increasing the size of a file system requires increasing the size of the logical volume first
D.Increasing the size of a file system also increases the size of the logical volume when necessary
第1题:
在程序中,用户输入一个文件名,根据用户输入显示相应文件的信息。
注意:请勿修改main()主方法和其他已有语句内容,仅在横线处填入适当语句。
______java.io.*;
public class basic
{
public static void main(String[] args)
{
InputStreamReader reader;
BufferedReader in;
System.out.println("请输入文件名: ");
try
{
reader=new InputStreamReader(______);
in=new BufferedReader(reader);
String filename=in.readLine();
File file=new File(filename);
System.out.println("文件名:"+file.______);
System.out.println("路径:"+file.getAbsolutePath());
System.out.println("大小:"+file.length());
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
第2题:
下列程序中,要求输出一个特定文件(这里是ex2_1.java)的相关信息,包括文件的名字,相对路径以及文件的长度。请将程序补充完整。
程序运行结果如下:
name:ex2_1.java
path:ex2_1.java
length: 299
import java.io.*;
public class ex2_1{
public static void main(String[] args) {
File file2_1 = new File("ex2_1.java");
System.out.println("name:"+file2_1.____________ );
System.out.println("path:"+file2_1.____________ );
System.out.println("length:"+file2_1.____________ );
}
}
第3题:
请解释R函数getwd()、setw()的作用,以及system.file(package = "base")的含义。
第4题:
import java.io.*;
import java.util.*;
public class FileClass {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
File file=new File(args[0]);
System.out.println(args[0]+"文件");
if(file.isFile()){
//是否为文件
System.out.print(file.canRead()?"可读":"不可读");
System.out.print(file.canWrite()?"可写":"不可写");
System.out.print(file.length()+"字节");//注意不能调用数组类型 File[] 的 length()例:File[] files=file.listFiles();不可以这么调用filess.length()
}
else{
//列出所有文件及目录
File[] files=file.listFiles();
ArrayList<File> fileList=new ArrayList<File>();
for(int i=0;i<files.length;i++){
//先列出目录
if(files[i].isDirectory()){
//是否为目录
//取得路径名
System.out.println("路径"+"[ "+files[i].getPath()+" ]");
}
else{
//文件先存入fileList,待会再列出
fileList.add(files[i]);
}
}
//列出文件
for(File f:fileList){
System.out.println(f.toString());
}
System.out.println();
}
}
catch(ArrayIndexOutOfBoundsException e){
System.out.println("using:java FileDemo pathname");
}
}
}
结果:using:java FileDemo pathname
是不是创建的对象所代表的文件没有被创建成功
File file=new File(args[0]); 就是创建一个args[0]所指文件路径的文件对象。出现异常的原因是:你把args[0]作为文件路径,而你运行时又没有指定。
第5题:
设有类定义如下:
class InOut{
String s= new String("Between");
public void amethod(final int iArgs){
int iam;
class Bicycle{
public void sayHello(){
//Here
}
}
}
public void another(){
int iOther;
}
}
以下哪些语句可以安排在//Here处 ?
A. System.out.println(s);
B.System.out.println(iOther);
C. System.out.println(iam);
D. System.out.println(iArgs);