Baca Tulis File

Tulis File

public boolean tulisFile(String txt){
try {
FileConnection fconn = (FileConnection)"file:///SDCard/data.conf",Connector.READ_WRITE);
if (!fconn.exists())
fconn.create();  // create the file if it doesn't exist
OutputStream os =fconn.openOutputStream();
return true;
catch (IOException ioe) {
return false;

baca file

public String bacaFile(){
try {
InputStream inputStream = null;
String resultString = null;
FileConnection fileConnection = (FileConnection) "file:///SDCard/data.conf");
if (fileConnection.exists()) {
inputStream = fileConnection.openInputStream();
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
while (true) {
int bytesRead = buffer, 0, 1024 );
if (bytesRead == -1)
byteArrayOutputStream.write( buffer, 0, bytesRead );
byte[] result = byteArrayOutputStream.toByteArray();
resultString = new String(result);
return resultString;
return null;

catch (IOException ioe) {
return null;

untuk import nya silahkan cari sendiri 😀
kalo pake eclipse akan mudah menemukannya

About iBNuX
Single fighter Developer

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: