Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Probelm in Path and Paths Classes

  1. #1
    Junior Member
    Join Date
    Jul 2009
    Location
    SomeWhere in the world
    Posts
    27
    Thanks
    1
    Thanked 11 Times in 6 Posts

    Default Probelm in Path and Paths Classes

    Hi Everybody.
    I'm trying to used these classes but i got an error about package.This is my sample
    import java.nio.file.Paths;
     
    public class UsingPaths {
    	public static void main(String args[])
    	{
     
    		Path path = Paths.get("C:\\30-6-2009\\Demo\\Threads");    // Microsoft Windows syntax
     
    		System.out.format("toString: %s%n", path.toString());
    		System.out.format("getName: %s%n", path.getName());
    		System.out.format("getName(0): %s%n", path.getName(0));
    		System.out.format("getNameCount: %d%n", path.getNameCount());
    		System.out.format("subpath(0,2): %d%n", path.subpath(0,2));
    		System.out.format("getParent: %s%n", path.getParent());
    		System.out.format("getRoot: %s%n", path.getRoot());
    		System.out.format("isHidden: %s%n", path.isHidden());
     
    	}
    }

    This sample actually in
    Path Operations (The Java™ Tutorials > Essential Classes > Basic I/O)
    How can i fix this problem.


  2. #2
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Probelm in Path and Paths Classes

    Wow this is above my head, I've not started using Java 7 yet. Do you have any specific error messages, stack traces or something?

    // Json

  3. #3
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Probelm in Path and Paths Classes

    Hello neo_2010.

    Can you please post the error you are getting..
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

  4. #4
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: Probelm in Path and Paths Classes

    What package did you put this file in? You must add the package <package name>; declaration at the top of the file.

  5. #5
    mmm.. coffee JavaPF's Avatar
    Join Date
    May 2008
    Location
    United Kingdom
    Posts
    3,336
    My Mood
    Mellow
    Thanks
    258
    Thanked 294 Times in 227 Posts
    Blog Entries
    4

    Default Re: Probelm in Path and Paths Classes

    Quote Originally Posted by helloworld922 View Post
    What package did you put this file in? You must add the package <package name>; declaration at the top of the file.
    I've got a feeling this will solve your problem neo!
    Please use [highlight=Java] code [/highlight] tags when posting your code.
    Forum Tip: Add to peoples reputation by clicking the button on their useful posts.

Similar Threads

  1. Program to print current directory path to the console
    By JavaPF in forum Java Programming Tutorials
    Replies: 1
    Last Post: October 9th, 2009, 12:59 PM
  2. [SOLVED] How to link two different class?
    By John in forum Object Oriented Programming
    Replies: 11
    Last Post: April 27th, 2009, 02:57 PM
  3. Why output is displaying 0 for calculation in java?
    By tazjaime in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 26th, 2009, 01:18 PM
  4. [SOLVED] Java program using two classes
    By AZBOY2000 in forum Object Oriented Programming
    Replies: 7
    Last Post: April 21st, 2009, 06:55 AM
  5. [SOLVED] How to a set java class path?
    By captjade in forum Java Theory & Questions
    Replies: 1
    Last Post: March 10th, 2009, 06:40 AM