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
android-fragments
livecode
bots
softlayer
subdomain
android-emulator
websocket
gentelella
supercollider
ui-automation
static-analysis
tup
eddystone
bellman-ford
phpstorm-2017.1
csrf
freertos
webstore
mahout-recommender
cpu-usage
parceler
intel
sybase-ase
mod-wsgi
jstree
web-push
offline-caching
msdeploy
openbravo
android-service
python-imageio
ccavenue
guice
appcode
listjs
counting
image-optimization
apptentive
xvfb
cartopy
mv
elastica
cheat-engine
widestring
reset
utf
grails3.2.0
flipkart
coverage.py
jqgrid-asp.net
asihttprequest
destroy
realstudio
nothing
android-sharing
swiperefreshlayout
maatwebsite-excel
java-2d
nsrunloop
svnserve
seccomp
perforce-integrate
timestamping
fdt
preferenceactivity
flipclock
jsr363
management-studio-express
teensy
myfaces
json-spirit
ibm-was
chicagoboss
calcite
enaml
unhandled
supersocket.net
green-threads
textscan
ipod
shoes
flurry-analytics
zend-mail
producer
qt5.4
accessory
webaii
principalcontext
django-settings
ctp
compiler-flags
unrealscript
chefspec
workflow-manager-1.x
coordinate
image-scanner
prefuse
flymake
series-40
n-queens
qt-mobility
fragment-identifier
webresponse
gaelyk
active-record-query
getimagesize
eventaggregator
wmd-editor
server-load
rootkit

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App