请问包怎么设置 编译是通过运行不了 找不到路径 有一个文件名为CH7的文件夹 是我的环境设置有问题还是什么
package ch7;
import java.io.*;
public class Test20
{
static String strFile="file20.dat";
public static void main(String[] args)
{
try
{
writeFile();
appendFile();
}
catch(IOException ioe)
{
System.out.println(ioe.getMessage());
}
}
static void writeFile()throws IOException
{
DataOutputStream dos=null;
try
{
File f=new File(strFile);
FileOutputStream fos=new FileOutputStream(f);
dos=new DataOutputStream(fos);
dos.writeBytes("Hello");
}
finally
{
if(dos!=null)
dos.close();
}
}
static void appendFile()throws IOException
{
RandomAccessFile raf=null;
try
{
File f=new File(strFile);
raf=new RandomAccessFile(f,"rw");
raf.seek(raf.length());
raf.writeBytes("ok");
}
finally
{
if(raf!=null)
raf.close();
}
}
}
----------------解决方案--------------------------------------------------------
你编译是用javac -d . Test20.java
java ch7.Test20来运行就可以了.
应该是路径的问题.
----------------解决方案--------------------------------------------------------
注意大小写
运行的时候,到包的外层目录里去执行
java ch7.Test20
----------------解决方案--------------------------------------------------------
谢谢各位了
问题以解决
----------------解决方案--------------------------------------------------------