freader.java

来自「mms application to allow user to send / 」· Java 代码 · 共 106 行

JAVA
106
字号
/***************************************************************************** Description: This class is used to connect to the files and folders on the phone.                     Created By: Oscar Vivall 2005-12-14 @file        FReader.java COPYRIGHT All rights reserved Sony Ericsson Mobile Communications AB 2004. The software is the copyrighted work of Sony Ericsson Mobile Communications AB. The use of the software is subject to the terms of the end-user license  agreement which accompanies or is included with the software. The software is  provided "as is" and Sony Ericsson specifically disclaim any warranty or  condition whatsoever regarding merchantability or fitness for a specific  purpose, title or non-infringement. No warranty of any kind is made in  relation to the condition, suitability, availability, accuracy, reliability,  merchantability and/or non-infringement of the software provided herein. *****************************************************************************/import javax.microedition.midlet.*;import javax.microedition.io.file.*;import javax.microedition.io.*;import java.util.*;import java.io.*;public class FReader {    private IFConn caller;    private String currentPath = "";        public FReader(IFConn caller){        this.caller = caller;    }    public String currentPath(){        return currentPath;    }        public void getRoot(){        System.out.println("getRoot");        new Thread(){            public void run(){                currentPath = "file:///";                try{                    Enumeration enum = FileSystemRegistry.listRoots();                    while(enum.hasMoreElements()){                        String file = (String)enum.nextElement();                        caller.folderArrival(file, true);                    }                }catch(Exception e){                    e.printStackTrace();                }            }        }.start();    }    public void getFolder(final String path){        System.out.println("getFolder:" + path);        new Thread(){            public void run(){                try{                    FileConnection fConn = (FileConnection)Connector.open(path);                    System.out.println("Is Folder:" + fConn.isDirectory() + " Can Read:" +fConn.canRead() + " Exist:" + fConn.exists());                    if(fConn.isDirectory() == true && fConn.exists() == true){                        currentPath = path;                        caller.folderArrival("../", true);                        Enumeration enum = fConn.list();                        while(enum.hasMoreElements()){                            String file = (String)enum.nextElement();                            System.out.println("file:" + file);                            boolean isFolder = false;                            if(file.charAt(file.length()-1) == '/'){                                isFolder = true;                            }                            caller.folderArrival(file, isFolder);                        }                        fConn.close();                    }                }catch(Exception e){                    e.printStackTrace();                }            }        }.start();    }    public void getFile(final String path){        System.out.println("getFile:" + path);                new Thread(){            public void run(){                try{                    FileConnection fConn = (FileConnection)Connector.open(path);                    if(fConn.isDirectory() == false && fConn.canRead() == true && fConn.exists() == true){                        InputStream is = fConn.openInputStream();                        caller.fileArrival(is);                        fConn.close();                    }                }catch(Exception e){                    e.printStackTrace();                }            }        }.start();    }    }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?