Click here to Skip to main content
13,046,474 members (71,112 online)
Rate this:
Please Sign up or sign in to vote.
See more:
In the below mentioned code I am writing dummy data to all files present in external storage and renaming to "abc.txt". But what I want is to write dummy data to only that file which I select and rename that particular file. How do I do?

File[] files = root.listFiles();
for ( File f : files ) {
if (f.isDirectory())
FileChannel rwChannel = new RandomAccessFile(f, "rw").getChannel();
int numBytes = (int)rwChannel.size();
ByteBuffer buffer =, 0, numBytes);
byte[] randomBytes = new byte[numBytes];
new Random().nextBytes(randomBytes);
File root1 = android.os.Environment.getExternalStorageDirectory();
File[] files1 = root.listFiles();
for ( File f : files ) {
if (f.isDirectory())
File myFile1 = new File(root,"abc.txt");
Posted 4-Jun-13 18:55pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 5 Jun 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100