Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

createNewFile( )

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
This is the code as below:
f.createFile( )
the complier show that that is a bug

code:
--------------------------------------------------------------------------------
import java.io.*;public class FileInfo{public static void main(String args[]){// open (or create) fileFile f= new File ("readme.txt");if( !f.exists())f.createNewFile();// display file informationSystem.out.println("File Information");System.out.println("Name:" + f.getName());System.out.println("Path:"+ f.getAbsolutePath());System.out.println("Size:" + f.length()+ "bytes");if(f.canRead())System.out.println("File can read");if(f.canWrite())System.out.println("File can be written to");f.delete();}}
--------------------------------------------------------------------------------

Do you know what wrong it is?
thanks
Larry
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to mention that your post is quite messy. First, if you post any code, put it between the CODE tags using the button below the text box where you enter the text. Next, you say that the compiler says that the expression f.createFile() has problems, but your code doesn't even seem to have that line, so I assume that you mean the expression f.createNewFile(). Third, you don't mention what does the compiler say about that line. Probably you are just not catching the IOException that the method can throw. Alternatively you can declare the main method to throw that exception.
[ September 11, 2002: Message edited by: Tanel Alumae ]
 
New rule: no elephants at the chess tournament. Tiny ads are still okay.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic