ioexception


java.io.IOException: The filename, directory name, or volume label syntax is incorrect Error while writing to HTTP directory


`I am writing a java code to upload files in HTTP server using JSF 2.0 wtih Servlet 3.0. When i am trying to uplaod the file to local system it works fine but if I specify the HTTP server url directory in http_path variable it gives "java.io.IOException: The filename, directory name, or volume label syntax is incorrect" error.
Also there are no issue while accessing the HTTP location using Web browser and i was successfully able to download files via java code if i give the HTTP path given in http_path(used in Bean.java)
While debugging it fails at file.createNewFile() line but if i specify local directory in http_path variable it doesnt give any problem;
Can someone please let me know whether the HTTP url path given in http_path variable is correct or am i missing any important code?
My Bean file:
#ManagedBean
#RequestScoped
public class Bean {
private UploadedFile uploadedFile;
public String submit() throws IOException {
String fileName = FilenameUtils.getName(uploadedFile.getName());
System.out.println("Uploaded File name is " + fileName);
byte[] bytes = uploadedFile.getBytes();
String http_path = "http://`172.21.11.108`/myhttp/";
URLConnection http = new URL(http_path).openConnection();
http.connect();
System.out.println("permisssion" + http.getPermission());
System.out.println("Url is " + http.getURL());
System.out.println("String" + http.getConnectTimeout());
FileOutputStream fop = null;
System.out.println("File name " + http_path + fileName);
File file = new File(http_path+fileName);
System.out.println("File path" + file.getPath());
if (!file.exists()) {
file.createNewFile();
System.out.println("entered file created");
}
fop = new FileOutputStream(file);
System.out.println("File name " + http_path + fileName);
fop.write(bytes);
fop.flush();
fop.close();
return "success";
}
Error in Glassfish logs:
INFO: File name is servlet_code_upload.txt INFO: File contentTypeis
text/plain INFO: permisssion(java.net.SocketPermission
172.21.11.108:80 connect,resolve) INFO: Url is http://172.21.11.108/myhttp/ INFO: String0 INFO: File name
http://172.21.11.108/myhttp/servlet_code_upload.txt INFO: File
pathhttp:`172.21.11.108`\myhttp\servlet_code_upload.txt
WARNING:
{bean.submit}: java.io.IOException: The filename, directory name, or volume label syntax is incorrect javax.faces.FacesException:
{bean.submit}: java.io.IOException: The filename, directory name, or volume label syntax is incorrect at
com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:118)
at javax.faces.component.UICommand.broadcast(UICommand.java:315) at
javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)
... 36 more Caused by: java.io.IOException: The filename, directory
name, or volume label syntax is incorrect at
java.io.WinNTFileSystem.createFileExclusively(Native Method) at
java.io.File.createNewFile(File.java:883) at
com.example.Bean.submit(Bean.java:59) at
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

Related Links

java.io.IOException: Incorrect configuration: namenode address dfs.namenode.servicerpc-address or dfs.namenode.rpc-address is not configured
How to cancel request using merge
PrintWriter doesn't seem to be writing to file even though I'm closing it
StreamWriter.Writeline throws “Not enough storage is available to process this command.” IO exception
IO Exception in OSMembrane while executing pipeline
Exception in thread Main Error java.lang.numberformat.exception
java.io.IOException: The filename, directory name, or volume label syntax is incorrect Error while writing to HTTP directory

Categories

HOME
svn
adfs3.0
schema.org
workflow
activex
whmcs
informatica
yql
dronekit-python
tcp
mathematical-optimization
liferay-7
qooxdoo
openflow
tfs2015
dji-sdk
phpmqtt
tweepy
swarm
lc3
responsivevoice
grocery-crud
createjs
jqxgrid
susy-sass
office-ui-fabric
uislider
generator
fluent-migrator
rxjs5
device
react-dnd
morris.js
msdeploy
oracleforms
math.js
mdns
tilemill
windows2012
john-the-ripper
lxml
overwrite
appcode
devtools
adminer
dreamfactory
busboy
runtimeexception
spinner
strapi
reset
word-cloud
minikube
transparency
permission-denied
asihttprequest
destroy
xcglogger
beeline
renderman
freshdesk
pen
gmaps.js
prefetch
java-2d
s-function
svnserve
gcloud-node
raw-sockets
xcode8-beta4
gulp-uglify
teamviewer
gwt-syncproxy
wif4.5
smart-tv
arbre
chicagoboss
netdatacontractserializer
wso2ml
blockquote
roxygen2
r.java-file
utf8-decode
windows-rt
full-text-indexing
siena
category-theory
pageviews
cidr
ctp
infinite
xsd2code
mousemotionlistener
django-facebook
google-code-prettify
red-system
dojo-1.9
jsplitpane
jdom
monocross
mkannotation
nosetests
digiflow
pyjamas
solandra
outlook-2007-addin
ppc

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App