Java Code Examples for javax.microedition.io.file.FileConnection#setReadable()

The following examples show how to use javax.microedition.io.file.FileConnection#setReadable() . 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: CanRead.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests canRead() on a readable 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("Setting file 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 file", passed);
}
 
Example 2
Source File: CanRead.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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: CanRead.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 4
Source File: CanRead.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests canRead() on a non-readable directory
 */
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);
			
			addOperationDesc("Setting directory 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 on-readable directory", passed);
}
 
Example 5
Source File: CanRead.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests canRead() on a file (readable 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 non-readable");
			conn.setReadable(false);
			
			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 file (readable attribute is NOT supported by filesystem)", passed);
}
 
Example 6
Source File: CanRead.java    From pluotsorbet with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Tests canRead() on a directory (readable attribute is NOT supported by filesystem)
 */
public void test0006() {
	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 non-readable");
			conn.setReadable(false);
			
			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 directory (readable attribute is NOT supported by filesystem)", passed);
}