• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

New to Java

 
Manikandan Sundaramoorthy
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manikandan,

Please the following piece of code--

 
Manikandan Sundaramoorthy
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Very much kayanaat sidiqui

Now its working... the application
 
kayanaat sidiqui
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my pleasure..
 
Campbell Ritchie
Sheriff
Pie
Posts: 49382
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch

Please always use thread titles which say what the thread is about. "New to Java" doesn't attract attention.
 
Manikandan Sundaramoorthy
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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) {
System.out.println(inputLine);



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
Posts: 15356
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic