当前位置: 首页>>代码示例>>Java>>正文


Java FileConnection.exists方法代码示例

本文整理汇总了Java中javax.microedition.io.file.FileConnection.exists方法的典型用法代码示例。如果您正苦于以下问题:Java FileConnection.exists方法的具体用法?Java FileConnection.exists怎么用?Java FileConnection.exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.microedition.io.file.FileConnection的用法示例。


在下文中一共展示了FileConnection.exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dumpRMS

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
public static void dumpRMS (String pathPrefix) {
    if (pathPrefix == null)
        pathPrefix = DUMP_PATH_PREFIX_DEFAULT;
    String filepath = dumpFilePath(pathPrefix);

    try {
        FileConnection fc = (FileConnection)Connector.open("file:///" + filepath);
        if (fc.exists()) {
            System.err.println("Error: File " + filepath + " already exists");
            fail("Dump file " + filepath + " already exists");
        }

        fc.create();
        DataOutputStream out = fc.openDataOutputStream();

        dumpRMS(out);

        fc.close();
    } catch (IOException ioe) {
        fail(ioe, "ioexception");
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:23,代码来源:DumpRMS.java

示例2: restoreRMS

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
public static void restoreRMS (String filepath) {
    if (filepath == null)
        filepath = RESTORE_FILE_PATH_DEFAULT;

    try {
        FileConnection fc = (FileConnection)Connector.open("file:///" + filepath);
        if (!fc.exists()) {
            System.err.println("Error: File " + filepath + " does not exist");
            fail("RMS image [" + filepath + "] not found");
        }

        restoreRMS(fc.openDataInputStream(), true);
        fc.close();
    } catch (IOException ioe) {
        fail(ioe, "ioexception");
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:18,代码来源:DumpRMS.java

示例3: generateData

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
void generateData() throws IOException {
    String str = "";
    String part = "abcdefghilmnopqrstuvzABCDEFGHILMNOPQRSTUVZabcdefghilmnopqrstuvzABCDEFGHILMNOPQRSTUVZ";
    for (int i = 0; i < 2000; i++) {
      str += part;
    }

    cbuf = new char[str.length()];
    cbufReader = new char[cbuf.length];
    str.getChars(0, str.length(), cbuf, 0);

    String dirPath = System.getProperty("fileconn.dir.private");
    file = (FileConnection)Connector.open(dirPath + "test");
    if (file.exists()) {
        file.delete();
    }
    file.create();
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:19,代码来源:UTF8Bench.java

示例4: startApp

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
public void startApp() {
    System.out.println("START - Background alarm started: " + startedBackgroundAlarm());

    receiveSMS();

    try {
        FileConnection file = (FileConnection)Connector.open("file:////startBackgroundService");
        if (!file.exists()) {
            file.create();
        }
        file.close();
    } catch (IOException e) {
        System.out.println("Unexpected exception: " + e);
        return;
    }

    System.out.println("DONE - Background alarm started: " + startedBackgroundAlarm());
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:19,代码来源:ForegroundEnableBackgroundServiceMIDlet.java

示例5: test0001

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * Tests delete() on a file
 */
public void test0001() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE);
		try {
			addOperationDesc("Creating file: " + conn.getURL());
			ensureFileExists(conn);
			
			addOperationDesc("Deleting file");
			conn.delete();
			boolean exists = conn.exists();
			addOperationDesc("exists() returned " + exists);

			passed = exists == false;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests delete() on a file", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:28,代码来源:Delete.java

示例6: test0002

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * Tests delete() on a directory
 */
public void test0002() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE);
		try {
			addOperationDesc("Creating directory: " + conn.getURL());
			ensureDirExists(conn);
			
			addOperationDesc("Deleting directory");
			conn.delete();

			boolean exists = conn.exists();
			addOperationDesc("exists() returned " + exists);

			passed = exists ==false;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests delete() on a file", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:29,代码来源:Delete.java

示例7: test0001

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * create() creates a new file
 */
public void test0001() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE);
		try {
			addOperationDesc("Deleting file: " + conn.getURL());
			ensureNotExists(conn);
			
			addOperationDesc("Creating file");
			conn.create();

			boolean exists = conn.exists();
			addOperationDesc("exists() returned " + exists);
			
			passed = exists==true;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("create() creates a new file", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:29,代码来源:Create.java

示例8: test0001

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * Tests exists() on a file
 */
public void test0001() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE);
		try {
			addOperationDesc("Creating file: " + conn.getURL());
			ensureFileExists(conn);
			
			boolean exists = conn.exists();
			addOperationDesc("exists() returned " + exists);
			
			passed = exists==true;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests exists() on a file", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:26,代码来源:Exists.java

示例9: test0003

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * Tests exists() on a non-existent file
 */
public void test0003() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE);
		try {
			addOperationDesc("Deleting file: " + conn.getURL());
			ensureNotExists(conn);
			
			boolean exists = conn.exists();
			addOperationDesc("exists() returned " + exists);
			
			passed = exists==false;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests exists() on a non-existent file", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:26,代码来源:Exists.java

示例10: test0004

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * Tests exists() on a non-existent directory
 */
public void test0004() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE);
		try {
			addOperationDesc("Deleting directory: " + conn.getURL());
			ensureNotExists(conn);
			
			boolean exists = conn.exists();
			addOperationDesc("exists() returned " + exists);
			
			passed = exists==false;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("Tests exists() on a non-existent directory", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:26,代码来源:Exists.java

示例11: test0007

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * Tests exists() in Connector.READ mode
 */
public void test0007() {
	boolean passed = false;
	try {	
		addOperationDesc("Opening connection in READ mode");
		FileConnection conn1 = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE);
		FileConnection conn2 = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ);
		try {
			addOperationDesc("Creating file: " + conn1.getURL());
			ensureFileExists(conn1);
			
			boolean exists = conn2.exists();
			addOperationDesc("exists() returned " + exists);
			
			passed = exists==true;						
		} finally {
			conn1.close();
			conn2.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}
	
	assertTrueWithLog("Tests exists() in Connector.READ mode", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:29,代码来源:Exists.java

示例12: test0001

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
public void test0001() {
	boolean passed = false;
	try {
		FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE);
		try {
			addOperationDesc("Deleting directory: " + conn.getURL());
			ensureNotExists(conn);
			
			addOperationDesc("Creating directory");
			conn.mkdir();

			boolean exists = conn.exists();
			addOperationDesc("exists() returned " + exists);

			passed = exists == true;
		} finally {
			conn.close();
		}
	} catch (Exception e) {
		logUnexpectedExceptionDesc(e);
		passed = false;
	}

	assertTrueWithLog("mkdir() creates a new directory", passed);
}
 
开发者ID:mozilla,项目名称:pluotsorbet,代码行数:26,代码来源:Mkdir.java

示例13: openOutputStream

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * @inheritDoc
 */
public OutputStream openOutputStream(Object connection) throws IOException {
    if(connection instanceof String) {
        FileConnection fc = (FileConnection)Connector.open((String)connection, Connector.READ_WRITE);
        if(!fc.exists()) {
            fc.create();
        }
        BufferedOutputStream o = new BufferedOutputStream(fc.openOutputStream(), (String)connection);
        o.setConnection(fc);
        return o;
    }
    return new BufferedOutputStream(((HttpConnection)connection).openOutputStream(), ((HttpConnection)connection).getURL());
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:16,代码来源:GameCanvasImplementation.java

示例14: openOutputStream

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
/**
 * @inheritDoc
 */
public OutputStream openOutputStream(Object connection) throws IOException {
    if (connection instanceof String) {
        FileConnection fc = (FileConnection) Connector.open((String) connection, Connector.READ_WRITE);
        if (!fc.exists()) {
            fc.create();
        }
        BufferedOutputStream o = new BufferedOutputStream(fc.openOutputStream(), (String) connection);
        o.setConnection(fc);
        return o;
    }
    OutputStream os = new BlackBerryOutputStream(((HttpConnection) connection).openOutputStream());
    return new BufferedOutputStream(os, ((HttpConnection) connection).getURL());
}
 
开发者ID:codenameone,项目名称:CodenameOne,代码行数:17,代码来源:BlackBerryImplementation.java

示例15: makeDirectory

import javax.microedition.io.file.FileConnection; //导入方法依赖的package包/类
private static boolean makeDirectory(String path) {
    try {
        FileConnection fc = (FileConnection) Connector.open(path, Connector.READ_WRITE);

        if (!fc.exists()) {
            fc.mkdir();
        }

        fc.close();
    } catch (IOException e) {
        return false;
    }

    return true;
}
 
开发者ID:yanex,项目名称:vika,代码行数:16,代码来源:DeviceMemory.java


注:本文中的javax.microedition.io.file.FileConnection.exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。