java


How to create directories using java in directories that require sudo rights?


I know how to create directories inside any directory using Java. But I am unable to find a solution to add directories inside a directory which requires sudo permission to create a directory inside it.
For eg, I want to create new directories named abc/abc inside /var/log/.
I am uisng following code :
public class CreateDirectories{
public static void main(String args[]){
File file = new File("/var/log/java-jdbc/java-jdbc");
if(!file.exists()){
if (file.mkdirs()) {
System.out.println("Directory is created!");
}
else{
System.out.println("Failed to create directory!");
}
}
}
}
This code always runs giving output: Failed to create directory!

Related Links

How to display BinaryTree in JTree java swing
Captcha validator; Client ip address in hibernate custom validator?
onActivityResult Failure delivering result ResultInfo
JAVA EE HIBERNATE CRITERIA API : add rows in database
Understanding ask, Whats the correct way using .save() and .commit() in Hibernate from the programming layers model Perspective
Get SearchHitField type using ElasticSearch Java API
netbeans 7.4 support for web application
EJB TransactionAttribute(TransactionAttributeType.REQUIRES_NEW) doesn'
Java and Tomcat org.json java.lang.ClassNotFoundException
EntityManager.find not retunring values
IntelliJ IDE does not detect Scala templates properly
Struts 2 : Displays table of Songs - null gets printed
upload csv file containing million values to a particular column in mysql
MovableObject java syntax error
Deferred Result in Spring MVC returning incorrect response
Using google static maps - JFrame or Javascript

Categories

HOME
pandas
pypi
gerrit
openmp
keras
zeromq
activiti
reserved
read-eval-print-loop
google-oauth
jxls
baqend
onelogin
slurm
numeral.js
ef-migrations
finite-automata
paging
abi
p-value
semantic-analysis
greendao
publish
opentype
windowbuilder
ecto
functor
airconsole
catalog
revolution-slider
restlet
jquery-bootgrid
automake
twitch
az-application-insights
ansible-playbook
leading-zero
opshub
password-encryption
heightmap
node-sass
thin
skeleton-css-boilerplate
komodoedit
dandelion
dropbox-php
colorama
worker-thread
font-size
np-complete
sybase-asa
namecoin
iso8601
spring-mongodb
bind9
setuptools
transmitfile
firebaseui
persist
ptrace
atk4
security-testing
emailrelay
graph-drawing
vstest.console.exe
graph-api-explorer
proj4js
streambase
javax.mail
formatjs
network-interface
hippomocks
braille
algebraic-data-types
srs
yui-compressor
flashvars
unc
osql
javax.script
imac
mysql-error-1005
icanhaz.js
forums
genealogy
grid-system
data-acquisition
django-notification

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