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

Using onDraw(Canvas) in GLSurfaceView
Decrypt a video and play parallelly
NoClassDefFoundError: Failed resolution of: Lokhttp3/internal/Platform
Print all the integers from 1 to 10^n that has the unique digits in it
N-Queen Backtracking
How can I make a list of steps not repeat in a recursive method?
How to remove and print every item in an IntStack object until it is empty?
SonarLint is unable to analyze file (Null Pointer Exception) with StringBuffer
.NET Reverse Proxy Server the Right Solution?
I want my Java program to play a song?
Accessing adress,states from longitude amd lattitude with google API
Optimization of deletion nodes in 2-d array
How to make an Application for Google TV remote in Android Programming?
A Java FileOutputStream that keeps the File?
Start webserver from VM arguments JAVA RMI ECPLISE
Break doesn't work in try with resources, but work in try without resources

Categories

HOME
yii2
google-chrome-extension
wso2-am
zeromq
xmpp
amortized-analysis
youtube-api-v3
rdf
twitter-bootstrap-4
binary-tree
survey
constraint-programming
uber-api
directx
paradox
node-notifier
communication
qt-creator
decomposition
percona
libtiff
after-effects
text-rendering
openedx
google-pagespeed
predix
grails3
amazonsellercentral
reverse-proxy
errorlevel
graphicsmagick
underflow
tooltipster
vision
iframe-resizer
kendo-ui-grid
ghost4j
y86
plsql-psp
multilingual
twitch
bootstrapper
hp-ux
avro4s
websphere-mq-fte
outlook-2013
smartcontracts
network-flow
theming
jquery-validate
dandelion
git-diff
nstextview
nativeapplication
pg-dump
webdriverjs
vtigercrm
prettytensor
dlna
yaws
asp.net5
srand
jms2
cannon.js
emailrelay
riak-cs
apache-commons-fileupload
apache-commons-net
python-green
operator-precedence
camanjs
jscript.net
tt-news
xceed-datagrid
jsctypes
pushbackinputstream
android-screen-support
limejs
lcs
distutils
automount
whoosh
window-management
nsobject
zpt
xdomainrequest
rfc1123
appender
coda-slider
getresponsestream
asp.net-profiles
multi-tier
adrotator
xetex
boost-smart-ptr
premature-optimization
sustainable-pace
port-number
commodore
windows-live-messenger

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