Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesJava Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 13th, 2000, 10:17 AM
randomx randomx is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Posts: 0 randomx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I am running JServ on linux and having trouble reading and writing files. My code works fine from a regular java application. Is there some trick to doing this from a servlet?

Reply With Quote
  #2  
Old November 13th, 2000, 11:24 AM
randomx randomx is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2000
Posts: 0 randomx User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Okay, so I'm that lame. hehe...

My bad code was my problem. To anyone with this same question, here is some code that actually works:
//////////////////////////
//READING:
try{
fis = new FileInputStream(getFullPath());
dis = new DataInputStream(fis);
while( dis.available() != 0)
{ System.out.println(dis.readLine());}
// I know, I know...
// readline() is deprecated... : (
dis.close();
}catch(IOException e)
{ System.out.println(e.toString());}

/////////////////////////////////////////
// Write something
FileOutputStream fos = null;
PrintStream p = null;
try{
// Create a new file output stream
fos = new FileOutputStream(getFullPath());
// Create a print stream using your new output stream
p = new PrintStream( fos );
//Write something in the file
p.println ("You are a freak!");
// free up the stream.
p.close();
}catch(IOException e)
{System.out.println("write file error" + e.toString());}

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > Servlet File I/O

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap