I am using java for my native. so here is my source:
Flex:
loadingLbl.visible=true;
var startTime:int = getTimer();
te1.text=""+startTime;
var file:File = File.desktopDirectory.resolvePath("samples/test.txt");
var pathFile:String = file.nativePath;
var stream:FileStream = new FileStream()
stream.open(file, FileMode.WRITE);
for(i=0; i<=100000; i++)
{
//list.dataProvider.addItem(""+i);
stream.writeUTFBytes("word"+i+"\n");
}
stream.close();
results.text=""+file.nativePath;
var currentTime:int = getTimer();
var timeRunning:int = (currentTime - startTime);
te0.text=""+currentTime;
timerLabel.text= "Total time: "+timeRunning+" ms";
loadingLbl.visible=false;
Android Version:
{
String temp="";
TextView time = (TextView)findViewById(R.id.timerLbl);
long start=System.nanoTime();
File sdcard = Environment.getExternalStorageDirectory();
//Get the text file
File myfile = new File(sdcard,"myFile.txt");
try {
BufferedWriter writer = new BufferedWriter(new FileWriter(myfile));
for(int i=0;i<100000;i++)
{
temp="word"+i;
writer.write(temp);
writer.newLine();
}
writer.flush();
writer.close();
} catch (FileNotFoundException e) {
// handle exception
} catch (IOException e) {
// handle exception
}
TextView tv = (TextView)findViewById(R.id.result);
//Set the text
tv.setText("Last word was: "+temp);
long end=System.nanoTime();
time.setText("Took: " + ((end - start) / 1000000+"ms"));
}
Can the difference of using bufferwriter be the source of getting different results?