• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

PrintWriter to txt file ( in package )  RSS feed

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


As you can see, I used method to print some text to a file. However I could just do " c:/users/t/desktop/iFaila.txt"
But this 'iFaila.txt.' is created in eclipse package. And I dont understand how to make work?
png11png.png
[Thumbnail for png11png.png]
 
Rancher
Posts: 3757
40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just to make sure I understand your problem.

Currently your code is creating the file in the "current directory", which is the directory that Java thinks it is running from.  You actually want it to create the file on the desktop?
 
bob john
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Dave Tolls wrote:Just to make sure I understand your problem.

Currently your code is creating the file in the "current directory", which is the directory that Java thinks it is running from.  You actually want it to create the file on the desktop?


I want "int darbuotojai & double medAlga" to be writted to "iFaila", who is located in lt.klpvm package.
I DONT WANT TO CREATE FILE ON DESKTOP.
 
Marshal
Posts: 6263
420
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch first

One thing you need to get right from the beginning is code formatting and indentation. As you may noticed, your code is all over the place. Before we move any forward, do this --> Ctrl + Shift + f (win keyboard) or Cmd + Shift + f (mac keyboard) and show us (re-post code by using code tags) how did it go.
 
bob john
Ranch Hand
Posts: 117
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Sheriff
Posts: 5458
147
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I DONT WANT TO CREATE FILE ON DESKTOP.



The above code will print to file iFails.txt in user t's desktop.  Where do you want the file to be created?
 
bob john
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:

I DONT WANT TO CREATE FILE ON DESKTOP.



The above code will print to file iFails.txt in user t's desktop.  Where do you want the file to be created?



Yes. BUT I DONT WANT to create file on desktop.

I want file to be created in project or in package. However I dont know how to define that directory.
 
Knute Snortum
Sheriff
Posts: 5458
147
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This will create iFaila.txt in the directory that Java is started in, usually the project directory.  For instance, I tested this out in a project call "Play" in my workspace directory.  So for me, the file would be in:

 C:\Users\Knute\workspace\Play

If you want it in a package, this is a little or complex.  In my Play project, I have a directory src where all my source code is.  In src I have the package net.snortum.play.  So if I wanted to put the file in the project directory, I would usr this code:

Note, no "/" at the beginning of the path.  Does this make sense?
 
bob john
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have found this file "iFaila.txt" in eclipse workplace directory.
But I dont understand, why it is invisible for package explorer?
package-explorer.png
[Thumbnail for package-explorer.png]
 
Knute Snortum
Sheriff
Posts: 5458
147
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you tried refreshing? (F5)
 
bob john
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Knute Snortum wrote:Have you tried refreshing? (F5)


Actually f5 dont works. i had to right-click on project to refresh. thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!