Android/Java - Best way to retrieve information from server? [closed] - java

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a server that stores a plain text file with a numerical value. The text file is constantly edited by the server every few minutes or so. What is the best way for an Android Client to retrieve the text file's contents?

The most efficient way would be using Volley library with a string request.

Do something like this:
URL url = new URL("http://www.domain.com/file.txt");
URLConnection urlConnection = url.openConnection();
urlConnection.setConnectTimeout(1000);
InputStream is = urlConnection.getInputStream();

Related

Postman Testing [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
I am trying to test in Postman a rest end point url. I am unable to upload a file and 2 JSON Objects, both at a time from Postman.
I can do it separately, I mean I can choose a file from form-data(Postman). Can send a JSON object from raw(Postman).But I cannot do at a time both.
Can some one please help me on this.
Using Body->form-data you can put your file and a JSON file(.json extension) with your JSON content.

How can i import some information result in website to my program [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm working on a project (java) that search for whois information for websites, so I started searching for a good websites that provides information about whois lookup, it could be easy for me if I find xml service.
This is the
the site that provides the information I want to get all the result to my program .
Somone have an idea ?
first step: to load
InputStream in = new URL("http://toolbar.netcraft.com/site_report?url=http://louisville.edu").openStream();
String content=IOUtils.toString(in);
in.close();
Second step: parse XML: use DOM, read some tutorial
for example: DOM XML Parser Example

How to create socket to receive both text and image [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to create a server which receives both text and image. For text I used DataInputStream dis.readUTF(), and for image, I used ObjectInputStream ois.readObject() to read the image as byte[]. So how can I write code to detect the data receiving is text or byte[]?
You'll have to use some kind of signal from the client to know whether it is sending text or an image.
Alternatively, you could receive on different ports depending on the type of input.

How to store and retrieve image in java? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to store image (upload) in database and retrieve it to jsp page. i am using JAVA and SQL SERVER 2012.
My table is imgtbl(name nvarchar(500),photo image)
Please help me
see this link for how to save an image to a DB. I am not sure that nvarchar is correct and I would rather go for a blob or similar.
Relevant code from link
("insert into save_image(name, city, image, Phone) "+ "values(?,?,?,?)");
psmnt.setString(1,"mahendra");
psmnt.setString(2,"Delhi");
psmnt.setString(4,"123456");
fis = new FileInputStream(image);
psmnt.setBinaryStream(3, (InputStream)fis, (int)(image.length()));
see also http://technet.microsoft.com/en-us/library/ms378813.aspx for a Microsoft bent on things.
Convert the image to bytes and save in database as blob.

Extracting data from sites [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to extract data from sites. I already got information from sites using the article extractor but now I want to get the information about events of a particular place. I want to get the events in that place when I give location as input.For example I want to extract information from this site "http://www.indianevents.org/events-Rajasthan-14.htm" I could be able to extract all events,festivals etc.
URL url;
url = new URL(str);
InputSource is = HTMLFetcher.fetch(url).toInputSource();
BoilerpipeSAXInput in = new BoilerpipeSAXInput(is);
TextDocument doc = in.getTextDocument();
news=ArticleExtractor.INSTANCE.getText(doc);
consider Apache Tika to download the text content
you can use stanford pos tagger to parse the text into
meaningful sentences
and NLP can help identify event information.
although writing this might sound simple (trust me its difficult).
Good Luck. :)

Categories