Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

IO question

 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can someone please explain this? Thanks.
Suppose we copy IO.class from C:\java\dir1 to c:\java

What will be the output of running "java IO" from C:\java.
a) C:\java\12345.msg
C:\java\..\12345.msg
b) C:\12345.msg
C:\java\..\12345.msg
c) C:\java\..\12345.msg
C:\java\\..\12345.msg
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what does IO.class do? Could you provide the source?
 
Holmes Wong
Ranch Hand
Posts: 163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Valentin Crettaz:
what does IO.class do? Could you provide the source?

I am sorry.
Here is the source:
Consider a directory structure like this (NT or 95)
C:\JAVA\12345.msg --FILE
\dir1\IO.class -- IO.class is under dir1
Consider the following code
import java.io.*;
public class IO {
public static void main(String args[]) {
File f = new File("..\\12345.msg");
try{
System.out.println(f.getCanonicalPath());
System.out.println(f.getAbsolutePath());
}catch(IOException e){
System.out.println(e);
}
}
}
[ February 20, 2002: Message edited by: Holmes Wong ]
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it question 38 ??
If yes then IO.class refers to the one presented in question 37 I guess...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic