Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

creating new files  RSS feed

 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know you can import an instance of a file by using...



but what if you wanted to create a file and then stick it in a
designated folder?

do you have to create a black .txt file and just ouput to it?

or can you actually "physically" create a new .txt file object within
a certain folder(which would have to be the folder the application currently resides).

just wanted to know...

Justin
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Justin Fox:
I know you can import an instance of a file by using...



but what if you wanted to create a file and then stick it in a
designated folder?

do you have to create a black .txt file and just ouput to it?

or can you actually "physically" create a new .txt file object within
a certain folder(which would have to be the folder the application currently resides).

just wanted to know...

Justin


Well Justin,

I didn't understand your question properly, what I get by your statements is you want to create a file at a certain location and then move that file from it's original position to another position.

Is that so..

let us know the exact problem??
 
Casper Maxwell
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably you meant "blank .txt file manually" instead of "black .txt file"

You can create new files as follows:

File file = new File(fileName);
file.createNewFile();

So if the filename "blank.txt" then the code snippet above creates an empty file named "blank.txt" in the current folder. (normally application folder)

And if you want to make sure that its directories exist before saving the file:

File dir = new File(dirName);
dir.mkdirs();
 
Justin Fox
Ranch Hand
Posts: 802
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you, thats what i needed to know...

but now i have a perdy dumb question...

i have folders on my desktop, and i want to change the color,
is there a way to do this without having to download a
folder modifying program?

thanks,
Justin
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!