想做一个下载文件到本地的程序,为什么编译不通过?
package j2me.download;
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import javax.microedition.io.*;
import java.io.*;
public class Download extends MIDlet{
private String strURL = "";
private HttpConnection httpCon = null;
private InputStream is = null;
private InputStreamReader isr = null;
private ByteArrayOutputStream baos = null;
public Download()
{
strURL = "http://localhost/aaa/Cab/18.CAB";
}
public void destroyApp(boolean b)
{
}
public void startApp()
{
System.out.println("connect to server...");
try
{
httpCon = (HttpConnection)Connector.open(strURL);
is = httpCon.openInputStream();
baos = new ByteArrayOutputStream();
int ch = 0;
while((ch=is.read())!=-1)
{
baos.write(ch);
}
byte[] b = baos.toByteArray();
FileOutputStream fos = new FileOutputStream("C:\\bbb.CAB");
fos.write(b);
}catch(Exception e)
{
e.printStackTrace();
}
}
public void pauseApp()
{
}
}
在jbuilder下编译通过了,但是在WTK104下编译却出错,这是为什么?
出错信息:
FileOutputStream fos = new FileOutputStream("C:\\bbb.CAB");
^
好像FileOutputStream不认识。