java - How to set up the path in newBufferWriter -



java - How to set up the path in newBufferWriter -

how can set path right newbufferwriter. i'm getting illustration usage of newbufferwriter oracle page:

charset charset = charset.forname("us-ascii"); string s = ...; seek (bufferedwriter author = files.newbufferedwriter(file, charset)) { writer.write(s, 0, s.length()); } grab (ioexception x) { system.err.format("ioexception: %s%n", x); }

i'm comfused how set file parameter, should path object, illustration want create file in directory , have set path object, , in code path object file parameter , how give string value ? or how give value of directory want create file ?

and else, exception ? mean ?

exception in thread "awt-eventqueue-0" java.lang.noclassdeffounderror: java/nio/file/path

if getting noclassdeffounderror java.nio.file.path there wrong java environment. mixing java versions; compiling jdk 7, trying run on java 6 or older. when type java -version?

path in java 7 more or less replacement file in java 6 , older.

you can path this:

path file = paths.get("myfile.txt");

java java-7 java.nio.file

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -