Java Code Examples for javax.microedition.io.file.FileConnection#delete()
The following examples show how to use
javax.microedition.io.file.FileConnection#delete() .
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: 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 2
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 3
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 4
Source File: DataInputOutputStreamFileBench.java From pluotsorbet with GNU General Public License v2.0 | 5 votes |
void runBenchmark() { try { long start; String dirPath = System.getProperty("fileconn.dir.private"); FileConnection file = (FileConnection)Connector.open(dirPath + "test"); if (file.exists()) { file.delete(); } file.create(); OutputStream fileOut = file.openOutputStream(); start = JVM.monotonicTimeMillis(); writeUTF(fileOut); System.out.println("DataOutputStream::writeUTF in file: " + (JVM.monotonicTimeMillis() - start)); InputStream fileIn = file.openInputStream(); start = JVM.monotonicTimeMillis(); readUTF(fileIn); System.out.println("DataInputStream::readUTF from file: " + (JVM.monotonicTimeMillis() - start)); file.close(); } catch (IOException e) { System.out.println("Unexpected exception: " + e); e.printStackTrace(); } }
Example 5
Source File: ImageProcessingBench.java From pluotsorbet with GNU General Public License v2.0 | 4 votes |
void runBenchmark() { try { long start, time = 0; client = (LocalMessageProtocolConnection)Connector.open("localmsg://nokia.image-processing"); DataEncoder dataEncoder = new DataEncoder("Conv-BEB"); dataEncoder.putStart(14, "event"); dataEncoder.put(13, "name", "Common"); dataEncoder.putStart(14, "message"); dataEncoder.put(13, "name", "ProtocolVersion"); dataEncoder.put(10, "version", "1.[0-10]"); dataEncoder.putEnd(14, "message"); dataEncoder.putEnd(14, "event"); byte[] sendData = dataEncoder.getData(); client.send(sendData, 0, sendData.length); LocalMessageProtocolMessage msg = client.newMessage(null); client.receive(msg); FileConnection originalImage = (FileConnection)Connector.open("file:////test.jpg", Connector.READ_WRITE); if (!originalImage.exists()) { originalImage.create(); } OutputStream os = originalImage.openDataOutputStream(); InputStream is = getClass().getResourceAsStream("/org/mozilla/io/test.jpg"); os.write(TestUtils.read(is)); os.close(); MemorySampler.sampleMemory("Memory before nokia.image-processing benchmark"); for (int i = 0; i < 1000; i++) { start = JVM.monotonicTimeMillis(); String path = scaleImage(); time += JVM.monotonicTimeMillis() - start; FileConnection file = (FileConnection)Connector.open(path); file.delete(); file.close(); } System.out.println("scaleImage: " + time); MemorySampler.sampleMemory("Memory after nokia.image-processing benchmark"); originalImage.delete(); originalImage.close(); client.close(); } catch (IOException e) { e.printStackTrace(); } }
Example 6
Source File: ContentHandlerMIDlet.java From pluotsorbet with GNU General Public License v2.0 | 4 votes |
public void startApp() { if (alreadyStarted) { return; } alreadyStarted = true; if (shouldStop()) { System.out.println("Test finished"); return; } try { Display.getDisplay(this).setCurrent(new TestCanvas()); // Wait MIDlet to become the foreground MIDlet synchronized (paintedLock) { while (!painted) { paintedLock.wait(); } } ContentHandlerServer chServer = Registry.getServer(getClass().getName()); // Check if the MIDlet has been invoked Invocation invoc = chServer.getRequest(false); if (invoc == null) { System.out.println("Invocation is null"); return; } String shareAction = invoc.getAction(); System.out.println("Invocation action: " + shareAction); String[] shareArgs = invoc.getArgs(); for (int i = 0; i < shareArgs.length; i++) { System.out.println("Invocation args[" + i + "]: " + shareArgs[i]); } FileConnection image = (FileConnection)Connector.open(shareArgs[0].substring(4), Connector.READ_WRITE); if (!image.exists()) { System.out.println("Image doesn't exist"); } else { System.out.println("Image exists"); image.delete(); } invoc.setArgs(null); chServer.finish(invoc, Invocation.INITIATED); } catch (Exception e) { System.out.println("Unexpected exception: " + e); } // Test that the Content Handler code works also if the MIDlet is already running. sendShareMessage(); }
Example 7
Source File: TestInputOutputStorage.java From pluotsorbet with GNU General Public License v2.0 | 4 votes |
public void test(TestHarness th) { try { FileConnection file = (FileConnection)Connector.open("file:////prova"); if (file.exists()) { file.delete(); } file.create(); RandomAccessStream ras = new RandomAccessStream(); ras.connect("prova", Connector.READ_WRITE); OutputStream out = ras.openOutputStream(); testWrite(th, out); out.close(); ras.setPosition(0); InputStream in = ras.openInputStream(); testRead(th, in); in.close(); ras.disconnect(); file.delete(); th.check(!file.exists()); file.create(); out = file.openOutputStream(); testWrite(th, out); out.close(); in = file.openInputStream(); testRead(th, in); in.close(); file.delete(); file.close(); } catch (Exception e) { th.fail("Unexpected exception: " + e); e.printStackTrace(); } }
Example 8
Source File: TestRandomAccessStream.java From pluotsorbet with GNU General Public License v2.0 | 4 votes |
void cleanup() throws IOException { FileConnection file = (FileConnection)Connector.open("file:////afile"); file.delete(); file.close(); }