java


How to set the owner of a file from a string variable


FileOwnerAttributeView FOAttr = Files.getFileAttributeView(VidFile.toPath(),FileOwnerAttributeView.class);
System.out.println(FOAttr.getOwner());
UserPrincipalLookupService lookupService = FileSystems.getDefault().getUserPrincipalLookupService();
UserPrincipal FileOwner = lookupService.lookupPrincipalByName(UName);
System.out.println(FileOwner.getName());
FOAttr.setOwner(FileOwner);
What I think is a relatively simple question; I am trying to change the file's owner using the code given. It actually works pretty well up until I try to set the string variable UName to a UserPrincipal - I have included the proper import libraries but when I try to execute the code I get the following :
Exception in thread "main"
java.nio.file.attribute.UserPrincipalNotFoundException at
sun.nio.fs.WindowsUserPrincipals.lookup(WindowsUserPrincipals.java:147)
at
sun.nio.fs.WindowsFileSystem$LookupService$1.lookupPrincipalByName(WindowsFileSystem.java:270)
at
metadataretrieval.MetadataRetrieval.main(MetadataRetrieval.java:213)
C:\Users\rolsen\AppData\Local\NetBeans\Cache\8.1\executor-snippets\debug.xml:83:
Java returned: 1
and now I am a bit confused... is there a trick to setting the UserPrincipal to a specific user at runtime when that user's name is in a string variable?
import java.nio.file.Files;
import java.nio.file.FileSystems;
import java.nio.file.attribute.FileOwnerAttributeView;
import java.nio.file.attribute.UserPrincipalLookupService;
import java.nio.file.attribute.UserPrincipal;

Related Links

Saving Button's text in my listview which is connected to SQLite Database
Android SQLite no such table exception
Would the garbage collector destroy my object in this case?
Actor name is not unique - AKKA
How to fix repeated pmd violations programatically? [duplicate]
Binding prefWidthProperty of ListView to widthProperty of containing AnchorPane breaks resizing of AnchorPane
Is Worth To Use MD5 If I Just Want To Get A Friendly Identify Of String
Excel formula (set using Apache POI) doesn't automatically calculate
Reading partition/directory /storage/extSdCard as a file, byte by byte. Android
Is there an event in Java Socket when socket receive data?
ScrollBar doesn't resize when a JFrame is maximized
Identifying, if there's duplicated inputted integer in Java
How to get original codes from generated pattern in java?
ListView with custom content in JavaFX
Is there a data structure to grab values by x or y?
Is it possible to modify the existing id in elasticsearch document?

Categories

HOME
azure-data-factory
path-finding
appx
vmware
kalman-filter
setup-deployment
amortized-analysis
blueprintjs
fingerprint
opengl-es-2.0
ios-charts
awesome-wm
user-input
midi
handsontable
jplayer
alignment
size
ef-migrations
google-static-maps
django-cms
lldb
kvc
php-openssl
claims-based-identity
wijmo
blazemeter
emgucv
su
info.plist
entitlements
assistant
socialengine
google-rich-snippets
directx-10
column-family
kendo-ui-grid
usbserial
protovis
android-kernel
mmenu
hexo
jmonkeyengine
host
main
dynamics-crm-2013
theano.scan
webix-treetable
trim
mesos-chronos
ruby-on-rails-3.1
sql-server-agent
gulp-sourcemaps
core-plot
android-mediaprojection
auto-update
xml-documentation
strptime
react-scripts
python-c-api
promela
celery-task
rdfs
forever
minimization
account-kit
chord-diagram
or-tools
messenger
angular-cache
httplistener
android-textview
intrusion-detection
asp.net-4.5
django-debug-toolbar
qpid
jwplayer7
flash-cs5
bluemix-app-scan
livequery
php-parse-error
revolution-r
cartesian-product
marching-cubes
jmeter-maven-plugin
wyam
map-projections
cakephp-3.1
responsive-images
oberon
bridge.net
gadt
java.util.concurrent
file-copying
mbr
mcts
pyhdf
commoncrypto
gridfs
tidy
ora-00911
chronoforms
interface-orientation
spring-validator
enter
assembly-loading
boost-filesystem
data-loss
coercion
psi
invite
cinema-4d
appendto
yui-datatable
xfbml
h.323
gin
getresponsestream
nerddinner

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