473,320 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

File input stream conflict from windows to linux?

InputStream in=null;
OutputStream out = null;
String webDirectory=/usr/local/jakarta/apache-tomcat-5.5.25/webapps/LaCoronaHotel-ForTesting2/images

String src = c:\samplepic.jpg

in = new FileInputStream(src);
fileName="/packages.gif";

out = new FileOutputStream(webDirectory+fileName);
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();


This is a part of my method

it is a web application where in i browse for the new picture and replace it with the existing one located on "webDirectory" ...
when i try it on my pc where the "webDirectory" is:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\LaCoronaHotel

it works


but right after i upload it on my hosting where it is hosted in a linux computer it doesnt work.. i get no error logs, it just wont work any ideas?? anything i might have missed?
is it possible to change a file from a windows to linux?
Jul 3 '08 #1
9 7579
JosAH
11,448 Expert 8TB
Just make sure those pathnames are correct and that you have read and write
permission in the source and destination. Linux doesn't do anything mysterious
to those files nor to their content.

kind regards,

Jos
Jul 3 '08 #2
r035198x
13,262 8TB
... and use relative file names. Read about ServletContext.
Jul 3 '08 #3
well i have 2 kinds of process one is that of the picture changing and the other is .txt

the .txt file is changing properly while that of the picture is not..
Jul 3 '08 #4
JosAH
11,448 Expert 8TB
well i have 2 kinds of process one is that of the picture changing and the other is .txt

the .txt file is changing properly while that of the picture is not..
Well, then the path to your .txt file seems to be correct while the path to your
.jpg file happens to be incorrect.

kind regards,

Jos
Jul 3 '08 #5
InputStream in=null;
OutputStream out = null;
String webDirectory=/usr/local/jakarta/apache-tomcat-5.5.25/webapps/LaCoronaHotel-ForTesting2/images

String src = c:\samplepic.jpg

in = new FileInputStream(src);
fileName="/packages.gif";

out = new FileOutputStream(webDirectory+fileName);
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();


this is my code

the error log tells me that fileNotFound exception on the variable "src".
i dont get it since this file is something i used from this page:
<input type="file"name="src">
when i use it on a windows based server it runs well but on the linux server it doesnt .

is there a particular something that i miss? or that i dont know of on linux?
Jul 3 '08 #6
r035198x
13,262 8TB
InputStream in=null;
OutputStream out = null;
String webDirectory=/usr/local/jakarta/apache-tomcat-5.5.25/webapps/LaCoronaHotel-ForTesting2/images

String src = c:\samplepic.jpg

in = new FileInputStream(src);
fileName="/packages.gif";

out = new FileOutputStream(webDirectory+fileName);
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();


this is my code

the error log tells me that fileNotFound exception on the variable "src".
i dont get it since this file is something i used from this page:
<input type="file"name="src">
when i use it on a windows based server it runs well but on the linux server it doesnt .

is there a particular something that i miss? or that i dont know of on linux?
If src points to c:\samplepic.jpg then you surely can't expect it to work on linux.
Jul 3 '08 #7
is there a way to copy this file to the linux directory?
Jul 3 '08 #8
r035198x
13,262 8TB
is there a way to copy this file to the linux directory?
How about reading about how to use relative file path names like I suggested above first?
Jul 3 '08 #9
How about reading about how to use relative file path names like I suggested above first?

since the programs aim is to change a particular picture:

i dont know how i will implement relative path names if i am to select a picture file from the windows directory. where do i put it?
note that the app is running on the linux server.
Jul 3 '08 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Sanyi | last post by:
I am having some trouble rereading a file for input. Here's the problem: I have a text file with some data (football scores) in its lines. First I read them line-by line to figure out how many...
3
by: Mario | last post by:
Hello, I couldn't find a solution to the following problem (tried google and dejanews), maybe I'm using the wrong keywords? Is there a way to open a file (a linux fifo pipe actually) in...
3
by: Debbie Carter | last post by:
Can XML files be easily encrypted?
68
by: vim | last post by:
hello everybody Plz tell the differance between binary file and ascii file............... Thanks in advance vim
17
by: Peter Duniho | last post by:
I searched using Google, on the web and in the newsgroups, and found nothing on this topic. Hopefully that means I just don't understand what I'm supposed to be doing here. :) The problem: ...
14
by: prasadjoshi124 | last post by:
Hi All, I am writing a small tool which is supposed to fill the filesystem to a specified percent. For, that I need to read how much the file system is full in percent, like the output given...
5
by: Brian | last post by:
Hi I have a problem in opening url using 'file'. I searched many other discussion groups and tried suggestions, but could not resolve this problem. e.g <?php $myfile =...
0
by: Craftkiller | last post by:
=========Program compiles on both windows and linux=========== Greetings, I am currently working on an encrpytion program that will take a file and a password string and flip the bits based on the...
27
by: =?ISO-8859-1?Q?Tom=E1s_=D3_h=C9ilidhe?= | last post by:
I have a fully-portable C program (or at least I think I do). It works fine on Windows, but malfunctions on Linux. I suspect that there's something I don't know about the standard input stream...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.