j2me写文件

FileConnection fc;
		try {
			String elem = null;
			Enumeration e = FileSystemRegistry.listRoots();
			while (e.hasMoreElements()) {
				elem = e.nextElement().toString();
			}
			System.out.println("::"+elem);
			fc = (FileConnection) Connector.open("file://localhost/" + elem+"a.txt");
			if (!fc.exists()) {
				fc.create();
				OutputStream is = fc.openOutputStream();
				is.write("abc".getBytes(), 0, "abc".length());
				is.flush();
				is.close();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

 在模拟器中 我使用的是wtk2.5.2 在代码中的路径写 file://localhost/root1/a.txt

这个文件实际是保存在 
C:\Documents and Settings\j\j2mewtk\2.5.2\appdb\DefaultColorPhone\filesystem\root1\ 

你可能感兴趣的:(C++,c,C#,J#)