File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes New to Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "New to Java" Watch "New to Java" New topic

New to Java

Manikandan Sundaramoorthy

Joined: Apr 09, 2009
Posts: 12
I know how to create a file but i want create a file with current time ... i don't know any one tell me
kayanaat sidiqui
Ranch Hand

Joined: Sep 04, 2008
Posts: 122
Hi Manikandan,

Please the following piece of code--

Manikandan Sundaramoorthy

Joined: Apr 09, 2009
Posts: 12
Thank you Very much kayanaat sidiqui

Now its working... the application
kayanaat sidiqui
Ranch Hand

Joined: Sep 04, 2008
Posts: 122
my pleasure..
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 46367
Welcome to JavaRanch

Please always use thread titles which say what the thread is about. "New to Java" doesn't attract attention.
Manikandan Sundaramoorthy

Joined: Apr 09, 2009
Posts: 12
Help Needed...

URL url = new URL(requestUrl.toString());
BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
String inputLine;
// System.out.println("-----RESPONSE START-----");
while ((inputLine = in.readLine()) != null) {

NodeList listOfPersons = inputLine.getElementsByTagName("Information");
int totalPersons = listOfPersons.getLength();
System.out.println("Total no of people : " + totalPersons);

for(int s=0; s<listOfPersons.getLength() ; s++){

Node firstPersonNode = listOfPersons.item(s);
if(firstPersonNode.getNodeType() == Node.ELEMENT_NODE){

Element firstPersonElement = (Element)firstPersonNode;

NodeList firstNameList = firstPersonElement.getElementsByTagName("Return_Msg");
Element firstNameElement = (Element)firstNameList.item(0);

NodeList textFNList = firstNameElement.getChildNodes();
System.out.println("First Name : " + ((Node)textFNList.item(0)).getNodeValue().trim());

First i'm reading xml file using http then i want to parse value i don't know how to call inputLine (that is in italic)

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15091

Welcome to JavaRanch.

Please use one thread per question - when you have a new question, just start a new topic, and don't post it as an answer in an existing topic.

Also, use code tags when you post source code, that makes it much easier to read.

About your question: inputLine is a String. Class String does not have a method called getElementsByTagName, so what you are trying to do doesn't work. In fact, when your code reaches the line:

NodeList listOfPersons = inputLine.getElementsByTagName("Information");

then inputLine will be null and even if this code would compile, you'd get a NullPointerException. It looks like you want to parse an XML file. You'll need to put the data from the response in an XML Document and extract the data that you're looking for from that.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: New to Java
It's not a secret anymore!