这样的事情可能吗?设计REST的人是否认为他们会永远删除一个东西?
所以,假设我有10个Foo的ID 1-10
我想通过一次HTTP DELETE调用删除ID的3,6和9.
在没有得罪教皇的情况下,我能做到这一点吗?
在我的应用程序,我想在一定条件下,类似的照片,当用户将其置于选择模式(Share复制一个工具栏等,按钮出现在标签栏),应用程序会发生什么一个工具栏,以取代的TabBar.我怎么能实现这个目标呢?
我正在开发应用程序,我必须实现直播电视流媒体.我的谷歌搜索让我相信直到2.1 android才能实现直播.
这样对吗?
当我获得媒体播放器的音乐代码时,我可以通过设置以下方法来使用它的类型:
mp.setAudioStreamType(2);
但我想知道它是否足以像这样流式传输代码并保存文件,如下面的方法:
private void setDataSource(String path) throws IOException {
if (!URLUtil.isNetworkUrl(path)) {
mp.setDataSource(path);
} else {
Log.i("enter the setdata","enter the setdata");
URL url = new URL(path);
URLConnection cn = url.openConnection();
cn.connect();
InputStream stream = cn.getInputStream();
if (stream == null)
throw new RuntimeException("stream is null");
File temp = File.createTempFile("mediaplayertmp", "dat");
String tempPath = temp.getAbsolutePath();
FileOutputStream out = new FileOutputStream(temp);
byte buf[] = new byte[128];
do {
int numread = stream.read(buf);
if (numread <= 0)
break;
out.write(buf, …Run Code Online (Sandbox Code Playgroud) 我有一个为单个线程编写的类,没有同步的方法.
class MyClass implements MyInterface{
//interface implementation methods, not synchronized
}
Run Code Online (Sandbox Code Playgroud)
但是我们还需要该类的同步版本.所以我们创建了一个包装类,它实现了相同的接口,但是有一个构造函数,它接受一个MyClass实例.对synchronized类的方法的任何调用都被委托给MyClass的实例.这是我的同步课程..
class SynchronizedMyClass implements MyInterface{
//the constructor
public SynchronizedMyClass(MyInterface i/*this is actually an instance of MyClass*/)
//interface implementation methods; all synchronized; all delegated to the MyInterface instance
}
Run Code Online (Sandbox Code Playgroud)
毕竟,我在这两个课程中进行了大量的测试.测试涉及读取日志文件和计算每行中的URL.问题是类的同步版本一直花费较少的时间进行解析.我只使用一个线程用于测试,因此没有死锁的机会,竞争条件等等.每个日志文件包含超过500万行,这意味着调用方法超过500万次.任何人都可以解释为什么班级迁移的同步时间比正常时间少吗?
请注意,这不是一个"好于"的讨论.
我是一名C++程序员,它让我感到非常愚蠢,不知道如何做很多Java文件IO.
我需要在文件中存储许多不同的数据类型,以便稍后读回.这些包括整数和可变长度的字符串.
在C++中,我可以使用:
//wont actually know the value of this
string mystr("randomvalue");
//the answer to the Ultimate Question of Life, the Universe, and Everything
int some_integer = 42;
//output stream
ofstream myout("foo.txt");
//write the values
myout << mystr << endl;
myout << some_integer << endl;
//read back
string read_string;
int read_integer;
//input stream
ifstream myin("foo.txt");
//read back values
//how to do accomplish something like this in Java?
myin >> read_string;
myin >> read_integer;
Run Code Online (Sandbox Code Playgroud)
非常感谢!