要素自动添加到一个数组 [英] Automatic adding of elements to an array

查看:129
本文介绍了要素自动添加到一个数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,我在Java的不特定的很好,所以请多多包涵。我想现在写了一个非常简单的Andr​​oid应用程序,我需要一些编码帮助。

Hi I'm not particular good at Java so please bear with me. I'm trying to write a very simple android app now and I need help with some coding.

事情是,我有一个自动生成.png文件,并将它们保存到一个公共目录中数字顺序的服务器。每天发生的更新和非穷尽的。

Thing is, I have a server that automatically generates .png files and saves them to a public directory in a numerical order. The update occurs daily and is non-exhaustive.

反正我在其中可分配动态值,以我的应用程序内的阵列?

Is there anyway in which I can assign the dynamic values to an array within my app?

            private String[] myRemoteImages = {
            "http://hypotheticalurl1.png",
            "http://hypotheticalurl2.png",
            "http://hypotheticalurl3.png",
            "http://hypotheticalurl4.png",
            "http://hypotheticalurl5.png",
            "http://hypotheticalurl6.png",
            "http://hypotheticalurl7.png",
            "http://hypotheticalurl8.png",
            "http://hypotheticalurl9.png",
            "http://hypotheticalurl10.png",
            "http://hypotheticalurl11.png",
            "http://hypotheticalurl12.png",
            //...blah blah blah
            // these are all dynamically created so I won't know what is the last number on the list
    };

这阵将最终被用于获取使用的应用程序从我的服务器映像。它的工作原理,但迄今为止,这只是硬codeD的URL。我想的URL是动态的,随着图像的数量将从一天一变。

This array will eventually be used to get the images from my server using the app. It works so far but that's only with hardcoded URLs. I would like the URLs to be dynamic, as the number of images will change from day to day.

我怀疑该正则表达式将在Java中工作得很好,但我还是那句话不是专家。正想着,也许就产生现有值的列表,服务器端的编写脚本并以某种方式解析,与Android应用程序。

I'm doubting that regex will work well in Java but then again I'm no expert. Was thinking of perhaps writing a script on the server end that generates a list of existing values and somehow parsing that with the android app.

任何人都可以点我在正确的方向?先谢谢了。

Can anyone point me in the right direction? Thanks in advance.

澄清:

该阵列不具备的应用程序运行时进行动态调整。

The array doesn't have to be dynamically sized while the app is running.

我需要一种方法来读取现有的图像列表中远程目录,并通过这些信息可以在运行时自动填充阵列。

I need a way to read the list of existing images in a remote directory and pass that information to populate the array automatically at runtime.

解决

Resolved

大家好,感谢您的帮助。很抱歉,如果我不太清楚。

Guys, thanks for the help. Sorry if I wasn't clear enough.

我已经找到一种方法来做到这一点。基本上,这是相当简单,这是code的一个额外的行追加到shell脚本在服务器端在它生成的图像,同时生成图像存在的URL的文本列表。

I've found a way to do it. Basically it was rather simple, which was to append an extra line of code to the shell script on the server end to generate a text list of existent image URLs at the same time that it generates the images.

在那之后,我使用的应用程序的BufferedReader和OpenStream的结合到远程文本文件解析成一个字符串数组。

After that, I used a combination of BufferedReader and openStream on the app to parse the remote text file into a String array.

推荐答案

感谢您的帮助。很抱歉,如果我不太清楚。

thanks for the help. Sorry if I wasn't clear enough.

我已经找到一种方法来做到这一点。基本上,这是相当简单,这是code的一个额外的行追加到shell脚本在服务器端在它生成的图像,同时生成图像存在的URL的文本列表。

I've found a way to do it. Basically it was rather simple, which was to append an extra line of code to the shell script on the server end to generate a text list of existent image URLs at the same time that it generates the images.

在那之后,我使用的应用程序的BufferedReader和OpenStream的结合到远程文本文件解析成一个字符串数组。

After that, I used a combination of BufferedReader and openStream on the app to parse the remote text file into a String array.

这篇关于要素自动添加到一个数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆