Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

writing files

 
Salvatore La Placa
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!I'm a beginner.I'm studying an article at http://wireless.java.sun.com/configurations/ttips/cldcconnect/
But I have problems running the example of class TestOutput for writing on a file.
I have modified it for running with j2me wireless toolkit:
import javax.microedition.midlet.MIDlet;
import javax.microedition.lcdui.*;
import java.io.*;
import javax.microedition.io.*;
public class TestOutput extends MIDlet {
TestOutput(){
try {
String uri = "file:c:/hah.txt;append=true";
OutputConnection conn = (OutputConnection)
Connector.open( uri, Connector.WRITE );
OutputStream out = conn.openOutputStream();
PrintStream print = new PrintStream( out );
conn.close(); // doesn't close output stream!
print.println( "Hah hah hah!" );
out.close();
}
catch( ConnectionNotFoundException e ){
System.out.println( "File could not be created!" );
}
catch( IOException e ){
System.out.println( e.toString() );
}
//System.exit( 0 );
}
public void startApp() {
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
}

Thank you.
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
CLDC does not support local files. The only persistent storage it supports is RMS.
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Salvo,
JavaRanch has a naming policy which is strictly enforced. Please read the policy and change your display name if you wish to continue posting here.
You can change your name: here
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic