IntelliJ Java IDE
The moose likes I/O and Streams and the fly likes what is wrong in this code Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Reply Bookmark "what is wrong in this code" Watch "what is wrong in this code" New topic
Author

what is wrong in this code

lp
Ranch Hand

Joined: Nov 08, 2000
Posts: 52
import java.io.*;
import java.util.*;
public class l1
{
public static void main(String [] args)
{
System.out.println("enter a value");
DataInputStream did =new DataInputStream(System.in);
System.out.println("lakshmipanda"+ did );
}
}
Maciej Kolodziej
Greenhorn

Joined: Feb 11, 2002
Posts: 26
But what do You want to do?
I can tell You what are You doing now. You created new DataInputStream attached to standard input. Than You printed dis.toString() which in this case is just class name and reference number.


MK
lp
Ranch Hand

Joined: Nov 08, 2000
Posts: 52
Hi
Actually the doubt i had was when i run this code i am getting an abstartc value and not the values entered .so i wanted to know incase i want to assign the input value to an integer format i have to parse the 'did' value ,but still mycode is giving me errors please help me in clearing this doubt
netharam ram
Ranch Hand

Joined: Aug 09, 2001
Posts: 202
import java.io.*;
import java.util.*;
public class l1
{
public static void main(String [] args)
{
try
{
byte[] data=new byte[50];
System.out.println("enter a value");
DataInputStream did =new DataInputStream(System.in);
did.read(data);
System.out.println("lakshmipanda " + new String(data) );
}catch(Exception e){System.out.println(e);}
}
}
Try this out.
Happy middling with java.
Netharam.
 
 
subject: what is wrong in this code
 
Threads others viewed
File path issues while reading an xsl file in java
exception example
Compile Java prg within Java prg, show errors
about DataInputStream class
IntelliJ Java IDE