I have still get error even if I used method that you suggest. I have
internet permission. My code piece that causes error is following:
String url = "ftp://username:[email protected]/test/
Button.apk";
is = new URL (url).openStream ();
Log is as follows:
08-26 01:50:27.958: WARN/System.err(4963): java.io.IOException: Unable
to connect to server: {0}
08-26 01:50:28.038: WARN/System.err(4963): at
org.apache.harmony.luni.internal.net.www.protocol.ftp.FtpURLConnection.connect
(FtpURLConnection.java:201)
08-26 01:50:28.038: WARN/System.err(4963): at
org.apache.harmony.luni.internal.net.www.protocol.ftp.FtpURLConnection.getInputStream
(FtpURLConnection.java:302)
08-26 01:50:28.038: WARN/System.err(4963): at
java.net.URL.openStream(URL.java:674)
08-26 01:50:28.038: WARN/System.err(4963): at
com.ska.connectServer.download_me(connectServer.java:133)
08-26 01:50:28.048: WARN/System.err(4963): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:
1123)
...
Thanks.
On Aug 26, 1:32 am, Jason Proctor <[email protected]>
wrote:
> ok. looks like the dalvik vm found a piece of java bytecode it didn't
> like. this can happen with some java compilers. one solution is to
> compile the FTP library yourself, if the source is available.
>
> HOWEVER
>
> another is to use plain old URL.openStream(), like this -
>
> InputStream is = null;
> FileOutputStream fos = null;
>
> try
> {
> String url = "ftp://user:passw...@host/path";
> is = new URL (url).openStream ();
>
> fos = new FileOutputStream ("/sdcard/yourfile");
>
> byte[] buffer = new byte [1024];
>
> for (int cc = is.read (buffer);
> cc > 0;
> cc = is.read (buffer))
> {
> fos.write (buffer, 0, cc);}
> }
>
> catch (Exception inException)
> {
> // log and report}
>
> finally
> {
> // close "is" and "fos" if they are not null, catch/ignore IOException
>
> }
>
> let us know how it goes,
>
> j
>
> >here is log file:
>
> >08-26 01:06:55.988: WARN/dalvikvm(1362): VFY: register1 v2 type 12,
> >wanted 11
> >08-26 01:06:55.988: WARN/dalvikvm(1362): VFY: rejecting opcode 0x71
> >at 0x0204
> >08-26 01:06:55.998: WARN/dalvikvm(1362): Exception Ljava/lang/
> >VerifyError; thrown during Lcom/jscape/inet/ftp/Ftp;.<clinit>
>
> --
> jason.vp.engineering.particle
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---