File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes the trouble of openInputStream()! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "the trouble of openInputStream()!" Watch "the trouble of openInputStream()!" New topic
Author

the trouble of openInputStream()!

goldfeng
Greenhorn

Joined: Sep 17, 2001
Posts: 1
when i use httpConnection to visit one file with name hello.txt, i have visited it successfully . but when I run it from the jad, there is the message of "Application error:IILegal Argument" on the screen of mobile phone . why?
Here is my code:
package testmidp;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;
public class firstExample extends MIDlet {
private Display display;
String url="http://localhost/hello.txt";
//String url=this.getAppProperty("url");
/**Construct the midlet*/
public firstExample() {
display=Display.getDisplay(this);
}
/**Main method*/
public void startApp() {
try
{
this.getViaStreamConnection(url);
}
catch(IOException e)
{
System.out.println("IOException: " + e);
e.printStackTrace();
}
}
/**Handle pausing the MIDlet*/
public void pauseApp() {
}
/**Handle destroying the MIDlet*/
public void destroyApp(boolean unconditional) {
}
void getViaStreamConnection(String url) throws IOException
{
StreamConnection c=null;
InputStream s=null;
StringBuffer b=new StringBuffer();
TextBox t=null;
try
{
c=(StreamConnection)Connector.open(url);
s=c.openInputStream();
int ch;
while((ch=s.read()) != 13)
{
b.append((char)ch);
}
System.out.println(b.toString());
t=new TextBox(url,b.toString(),1024,0);
}
finally
{
if(s!=null)
s.close();
if(c!=null)
c.close();
}
display.setCurrent(t);
}
}
shailesh sonavadekar
Ranch Hand

Joined: Oct 12, 2000
Posts: 1874
goldfeng , Welcome to javaranch.
PROPER NAMES ARE NOW REQUIRED
Please look carefully at official naming policy at javaranch & reregister yourself with proper first & last name. Please adhere to official naming policy & help maintain the decorum of the forum.
Waiting for your posts with proper first & last name. Once you have reregister , please let us know about that & then your previous account will be disabled.
Regards.

Your Friendly Bartender
Shailesh.
gold feng
Greenhorn

Joined: Sep 25, 2001
Posts: 5
I had found the answer. When I tested it in WhiteBoard 2.0 , It worked well. So it was the bug of Jbuilder.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: the trouble of openInputStream()!