Join Our 3 MILLION+ Members Today! Register Here | Login
Go Back   BlackBerry Forums at CrackBerry.com > BlackBerry Professionals > App Developers

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
    Thread Author   #1  
Old 09-26-2010, 09:01 AM
CrackBerry User
Device(s): 9700 (Bold)
Carrier: Vodafone
 
Join Date: Apr 2010
Posts: 10
Likes Received: 0
Thanked 0 Times in 0 Posts
Default openDataOutputStream() File system error (12)

the code on line "outstream = fileconn.openDataOutputStream();" (full code attached below) throws an exception with message "File system error (12)" ?

the funny thing is that the exception is not thrown the first time the WriteXml(); is called i.e. on first call during every lifetime of the application, the file writing completes successfully, but all subsequent calls after the first one fail and throw this file system error??? our application works by first reading an xml file, and then writing one (WriteXml()) if the user presses Save (which works first time), but if the user presses Save again, the writing does not work any more.

when i close the application and start it again, the first save works fine again, but not the following ones? any ideas how to solve this issue?


cheers.

Code:
import javax.microedition.io.Connector;
import javax.microedition.io.file.FileConnection;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import net.rim.device.api.ui.component.Dialog;
import org.kxml2.io.KXmlParser;
import org.kxml2.io.KXmlSerializer;
import org.kxml2.kdom.Document;
import org.kxml2.kdom.Element;
import org.kxml2.kdom.Node;

public class Filer {

	
private String filepath = "file:///SDCard/Blackberry/TelliT.xml";
	private String ip = "192.168.1.1";
	private String port = "80";

public void WriteXml() {

try {
			FileConnection fileconn = (FileConnection) Connector.open(filepath,
					Connector.READ_WRITE);
			if (!fileconn.exists()) {
				fileconn.create();
			}

			Document doc = new Document();
			Element root = doc.createElement("", "TelliT");
			Element server = doc.createElement("", "server");

			Element ipelem = doc.createElement("", "ip");
			ipelem.addChild(Node.TEXT, ip);

			Element portelem = doc.createElement("", "port");
			portelem.addChild(Node.TEXT, port);

			server.addChild(Node.ELEMENT, ipelem);
			server.addChild(Node.ELEMENT, portelem);

			root.addChild(Node.ELEMENT, server);
			doc.addChild(Node.ELEMENT, root);

			DataOutputStream outstream;

			outstream = fileconn.openDataOutputStream();
			KXmlSerializer serializer = new KXmlSerializer();
			serializer.setOutput(outstream, "UTF-8");
			doc.write(serializer);
			fileconn.close();

		} catch (Exception e) {
			Dialog.alert("Data could not be saved: " + e.getMessage());
		}

}

}
Reply With Quote Tip this Post
    Thread Author   #2  
Old 09-26-2010, 10:44 AM
CrackBerry User
Device(s): 9700 (Bold)
Carrier: Vodafone
 
Join Date: Apr 2010
Posts: 10
Likes Received: 0
Thanked 0 Times in 0 Posts
Default

found a solution at supportforums.blackberry.com/t5/Java-Development/openDataOutputStream-File-system-error-12/m-p/601129/highlight/false#M124905

already!
Reply With Quote Tip this Post
Reply
BlackBerry Forums at CrackBerry.com > > BlackBerry Professionals > App Developers   openDataOutputStream() File system error (12)

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes