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

Writing/Reading Files  RSS feed

 
Jesse Walker
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where is a good place to learn(other then Javadocs) about the functionality of the java.io package, and any other packages that can read/write to a drive. I am also looking for any information that would allow java to write to an existing Excel spreadshee/ Word document. I attempted to google it but may not be searching for the right keywords.
Thank you,
Jesse
 
Kevin Ott
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


There are lots more examples of working with files posted at:

http://www.exampledepot.com/egs/java.io/pkg.html
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Readers and writers and streams and buffers are enough to be pretty confusing awright. The free online version of Thinking In Java has a nice chapter on the IO package.

There are several packages to do IO to Excel. "Poi" is the only one that comes to mind. I have no hands on with any of them, but I'm sure folks will jump in with details.

Another option I've used but cannot highly recommend is to open an Excel sheet as a database with JDBC/ODBC.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ofcourse the chapter Basic I/O of Sun's Java Tutorial is also a good place to learn about I/O.

I don't know what keywords you used in Google, but if you search for "java excel" or "java excel api" you'll find lots of information.
[ December 05, 2006: Message edited by: Jesper Young ]
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For reading and writing Excel files there are a number options (foremost POI and jExcelapi). For Word the options are more limited; have a look at POI, Wordapi and OpenOffice. Links to all these are on the AccessingFileFormats wiki page.
 
Jesse Walker
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do you set your default working directory when working with the java.io package?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't. The "current directory" (the path where relative paths are resolved from) is the directory that you started your Java process from. So if you're for example in C:\mystuff\project, and you type in "java mypackage.MyProgram" on the command line, then C:\mystuff\project will be the "current directory".

There are ways to get the home directory of the user that's logged in:

String homeDir = System.getProperty("user.home");

But that's not the same as the "current directory".

There is no way to set the "current directory".

If you don't want your program to be dependent on from which directory the Java process is started, you should use absolute paths in your program instead of relative paths.
[ December 07, 2006: Message edited by: Jesper Young ]
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!