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

createWrite( )

 
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


Do you know what wrong it is?
thanks
Larry
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What specific problem are you having?
 
Larry Lai
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 Ron,
How're you ?
I mean the complier reply that the f.createFile( )
causes the problem.
I'm not sure what wrong it is...
Larry
 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I still don't understand. What is the compiler saying? Show us the entire error message.
 
Larry Lai
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 Ron,

the compiler replys about as below:


--------------------Configuration: JDK version 1.31 <Default>--------------------
C:\Documents and Settings\labuser\Desktop\FileInfo.java:11: unreported exception java.io.IOException; must be caught or declared to be thrown
if( !f.exists())f.createNewFile();
^
1 error
Process completed.

 
Ron Newman
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's fairly self-explanatory, no? If you call the method f.createNewFile(), you need to do so within a try-block that catches IOException.
I don't know exactly what IO exceptions can arise, but I'd guess one of them will occur if the file name isn't valid, includes directories that don't actually exist, or names a file that can't be created because you don't have the right permissions.
[ September 04, 2002: Message edited by: Ron Newman ]
 
I've never won anything before. Not even a tiny ad:
The trailboss has a kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic