Win a copy of Head First Android this week in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

who can help me?

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
who can help me?I have the code.
try
{ //creat inputStream myfile Object.
RandomAccessFile fileIn= new RandomAccessFile("myfile.txt","rw");
long filePointer=0;
long length=fileIn.length();
while(filePointer<length)
{
String s=fileIn.readLine();
s=s.substring(7);
System.out.println(s);
filePointer=fileIn.getFilePointer();
}
}catch(Exception e){
String err=e.toString();
System.out.println(err);
}

How can i get a varable file path and not the invarable file path "myfile.txt". Thanks .
 
Ranch Hand
Posts: 342
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
I'm not 100% sure I understand the question as you don't say what type of program you are using. I'm assuming a GUI application, you can use something like a load file dialog to pick up a file like this and store it's location in a string variable "file_var"....

In the FileDialog constructor "this" refers to a parent GUI object to which the dialog belongs (e.g. JFrame).
Hope this helps!
 
reply
    Bookmark Topic Watch Topic
  • New Topic