javax.microedition.io.file.FileConnection Java Examples
The following examples show how to use
javax.microedition.io.file.FileConnection.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Mkdir.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
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); }
Example #2
Source File: CanRead.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests canRead() on a non-readable file */ public void test0002() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE); try { addOperationDesc("Creating file: " + conn.getURL()); ensureFileExists(conn); addOperationDesc("Setting file as non-readable"); conn.setReadable(false); boolean canRead = conn.canRead(); addOperationDesc("canRead() returned " + canRead); passed = canRead==false; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests canRead() on a non-readable file", passed); }
Example #3
Source File: UTF8Bench.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
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(); }
Example #4
Source File: ForegroundEnableBackgroundServiceMIDlet.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
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()); }
Example #5
Source File: GetName.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests getName() on an existing directory url */ public void test0004() { boolean passed = false; try { String url="file://"+getTestPath()+"dir/"; FileConnection conn = (FileConnection)Connector.open(url, Connector.READ_WRITE); ensureDirExists(conn); try { addOperationDesc("Using directory url: " + url); String name = conn.getName(); addOperationDesc("getName() returned " + name); passed = "dir/".equals(name); } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests getName() on an existing directory url", passed); }
Example #6
Source File: AvailableSize.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests availableSize() in Connector.READ mode */ public void test0005() { boolean passed = false; try { addOperationDesc("Opening connection in READ mode"); FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ); try { long availableSize = conn.availableSize(); addOperationDesc("availableSize() call returned " + availableSize); passed = true; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests availableSize() in Connector.READ mode", passed); }
Example #7
Source File: GetName.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests getName() on an encoded file URL */ public void test0007() { boolean passed = false; try { String url="file://"+getTestPath()+"foo%5e%25bar"; FileConnection conn = (FileConnection)Connector.open(url, Connector.READ_WRITE); try { addOperationDesc("Using file url: " + url); String name = conn.getName(); addOperationDesc("getName() returned " + name); passed = "foo^%bar".equals(name); } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests getName() on an encoded file URL", passed); }
Example #8
Source File: CanWrite.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests canWrite() in Connector.READ mode */ public void test0009() { boolean passed = false; try { addOperationDesc("Opening connection in READ mode"); FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ); try { boolean canWrite = conn.canWrite(); addOperationDesc("canWrite() call returned " + canWrite); passed = true; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests canWrite() in Connector.READ mode", passed); }
Example #9
Source File: CanWrite.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests canWrite() on a non-existent file */ public void test0010() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE); try { addOperationDesc("Deleting file: " + conn.getURL()); ensureNotExists(conn); boolean canWrite = conn.canWrite(); addOperationDesc("canWrite() returned " + canWrite); passed = canWrite==false; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("canWrite() returns false for a non-existent file", passed); }
Example #10
Source File: CanWrite.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests canWrite() on a non-existent file (writable attribute is NOT supported by filesystem) */ public void test0011() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE); try { addOperationDesc("Deleting file: " + conn.getURL()); ensureNotExists(conn); boolean canWrite = conn.canWrite(); addOperationDesc("canWrite() returned " + canWrite); passed = canWrite==false; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("canWrite() returns false for a non-existent file (writable attribute is NOT supported by filesystem)", passed); }
Example #11
Source File: CanWrite.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests canWrite() on a non-existent directory */ public void test0012() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE); try { addOperationDesc("Deleting directory: " + conn.getURL()); ensureNotExists(conn); boolean canWrite = conn.canWrite(); addOperationDesc("canWrite() returned " + canWrite); passed = canWrite==false; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("canWrite() returns false for a non-existent directory", passed); }
Example #12
Source File: CanWrite.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests canWrite() on a non-existent directory (writable attribute is NOT supported by filesystem) */ public void test0013() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE); try { addOperationDesc("Deleting directory: " + conn.getURL()); ensureNotExists(conn); boolean canWrite = conn.canWrite(); addOperationDesc("canWrite() returned " + canWrite); passed = canWrite==false; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("canWrite() returns false for a non-existent directory (writable attribute is NOT supported by filesystem)", passed); }
Example #13
Source File: FileSize.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests fileSize() 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 with a size of 64 bytes: " + conn.getURL()); ensureFileExists(conn); ensureFileSize(conn, 64); long fileSize = conn.fileSize(); addOperationDesc("fileSize() returned " + fileSize); passed = fileSize==64; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests fileSize() on a file", passed); }
Example #14
Source File: TotalSize.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests totalSize() in Connector.READ mode */ public void test0006() { boolean passed = false; try { addOperationDesc("Opening connection in READ mode"); FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ); try { long totalSize = conn.totalSize(); addOperationDesc("totalSize() call returned " + totalSize); passed = true; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests totalSize() in Connector.READ mode", passed); }
Example #15
Source File: IsHidden.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests isHidden() on a non-existent directory (hidden attribute is NOT supported by filesystem) */ public void test0013() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE); try { addOperationDesc("Deleting directory: " + conn.getURL()); ensureNotExists(conn); boolean isHidden = conn.isHidden(); addOperationDesc("isHidden() returned " + isHidden); passed = isHidden==false; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("isHidden() returns false for a non-existent directory (hidden attribute is NOT supported by filesystem)", passed); }
Example #16
Source File: CanRead.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests canRead() on a readable directory */ public void test0003() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE); try { addOperationDesc("Creating directory: " + conn.getURL()); ensureDirExists(conn); addOperationDesc("Setting directory as readable"); conn.setReadable(true); boolean canRead = conn.canRead(); addOperationDesc("canRead() returned " + canRead); passed = canRead==true; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests canRead() on a readable directory", passed); }
Example #17
Source File: TotalSize.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests totalSize() as the sum of usedSize() and availableSize() */ public void test0003() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE); try { long totalSize = conn.totalSize(); addOperationDesc("totalSize()="+totalSize); long totalSize2 = conn.availableSize() + conn.usedSize(); addOperationDesc("availableSize()+usedSize()="+totalSize2); passed = totalSize == totalSize2; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests totalSize() as the sum of usedSize() and availableSize()", passed); }
Example #18
Source File: TotalSize.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests totalSize() */ public void test0001() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE); try { long totalSize = conn.totalSize(); addOperationDesc("totalSize() returned " + totalSize); passed = totalSize > 0; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests totalSize()", passed); }
Example #19
Source File: Delete.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * 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); }
Example #20
Source File: Delete.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * 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); }
Example #21
Source File: LastModified.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
public void test0004() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE); try { addOperationDesc("Creating directory: " + conn.getURL()); ensureDirExists(conn); long modifyTime = conn.lastModified(); addOperationDesc("lastModified() returned " + modifyTime); passed = modifyTime == 0; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests lastModified() on a directory (modification date is NOT supported by filesystem)", passed); }
Example #22
Source File: UsedSize.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests usedSize() in Connector.READ mode */ public void test0005() { boolean passed = false; try { addOperationDesc("Opening connection in READ mode"); FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ); try { long totalSize = conn.usedSize(); addOperationDesc("usedSize() call returned " + totalSize); passed = true; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests usedSize() in Connector.READ mode", passed); }
Example #23
Source File: DirectorySize.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests directorySize() on empty directory */ public void test0001() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE); try { addOperationDesc("Creating directory: " + conn.getURL()); ensureDirExists(conn); long directorySize = conn.directorySize(true); addOperationDesc("directorySize(true) returned " + directorySize); passed = directorySize==0; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests directorySize() on empty directory", passed); }
Example #24
Source File: DirectorySize.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests directorySize() in Connector.READ mode */ public void test0008() { boolean passed = false; try { addOperationDesc("Opening connection in READ mode"); FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ); try { long directorySize = conn.directorySize(false); addOperationDesc("directorySize() call returned " + directorySize); passed = true; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests directorySize() in Connector.READ mode", passed); }
Example #25
Source File: DirectorySize.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests directorySize() on a non-existent directory */ public void test0009() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"testdir/", Connector.READ_WRITE); try { addOperationDesc("Deleting directory: " + conn.getURL()); ensureNotExists(conn); long directorySize = conn.directorySize(true); addOperationDesc("directorySize(true) returned " + directorySize); passed = directorySize==-1; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests directorySize() on a non-existent directory", passed); }
Example #26
Source File: IsHidden.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests isHidden() on a file (hidden attribute is NOT supported by filesystem) */ public void test0005() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE); try { addOperationDesc("Creating file: " + conn.getURL()); ensureFileExists(conn); addOperationDesc("Setting file as hidden"); conn.setHidden(true); boolean isHidden = conn.isHidden(); addOperationDesc("isHidden() returned " + isHidden + " (should have no effect)"); passed = isHidden==false; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests isHidden() on a file (hidden attribute is NOT supported by filesystem)", passed); }
Example #27
Source File: LastModified.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
public void test0002() { boolean passed = false; try { FileConnection conn = (FileConnection)Connector.open("file://"+getTestPath()+"test", Connector.READ_WRITE); try { addOperationDesc("Creating file: " + conn.getURL()); ensureFileExists(conn); long modifyTime = conn.lastModified(); addOperationDesc("lastModified() returned " + modifyTime); passed = modifyTime == 0; } finally { conn.close(); } } catch (Exception e) { logUnexpectedExceptionDesc(e); passed = false; } assertTrueWithLog("Tests lastModified() on a file (modification date is NOT supported by filesystem)", passed); }
Example #28
Source File: Exists.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * Tests exists() 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); 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 directory", passed); }
Example #29
Source File: Exists.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * 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); }
Example #30
Source File: Exists.java From pluotsorbet with GNU General Public License v2.0 | 6 votes |
/** * 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); }