Win a copy of Java 9 Revealed this week in the Features new in Java 9 forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

creating file  RSS feed

 
jyothi abraham
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1)you can create a RAFfile using constructor
RandomAccessFile rf = new RandomAccessFile("data.txt","r");
Similarly how can I create other types of files (using any IO
class)?

[This message has been edited by jyothi abraham (edited October 30, 2001).]
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm moving this to Streams and IO

------------------
Valentin Crettaz
Sun Certified Programmer for Java 2 Platform
 
Peter Chase
Ranch Hand
Posts: 1970
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.io.File provides createNewFile(), for example. So, you create a File object describing the file that you want, then call createNewFile() on it.
You can have a java.io.File object that does not refer to an existing physical file. For instance, you may not have created the physical file, or it may have existed, but you have deleted it (with delete() ).
RandomAccessFile is different. When you construct RandomAccessFile, it creates a physical file, if none yet exists.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!