Command Shell for a mobile phone

2019-08-20 04:32发布

I am working on a project for builiding a shell for a java enabled mobile phone(using J2ME).I have to demonstarte 3 commands 1) ls 2) top 3)cat .How to implement them?Plese give me some ideas.Thanking you.

标签: java-me
2条回答
趁早两清
2楼-- · 2019-08-20 05:06

You can use JSR 75 [File Connection API] to list out the files, which can be used to implement 'ls' command and using the same, you can implement the 'cat' command also.

However beware of the permissions, your app needs to be signed to be effective, otherwise for each subsequent requests to the file-system, the OS will be asking the user for permission, destroying the concept of a shell!

'top' can't be implemented in J2ME

Sample for File Connection API: File Sample

查看更多
做个烂人
3楼-- · 2019-08-20 05:07

Download Coreutils (it's the package which contains all of these commands): http://ftp.gnu.org/gnu/coreutils/coreutils-8.9.tar.gz.

Rip it open, and find the source code for each one. I think the tarball is organized quite nicely.

And some implementations of the commands in other languages (I like Python, as it's readable):

  1. ls: http://www.pixelbeat.org/talks/python/ls.py.html.
  2. cat: http://www.unix.com/302420159-post2.html.
  3. top is complicated. Good luck implementing it!
查看更多
登录 后发表回答