我正在使用以下命令将图像序列转换为视频.
ffmpeg -r 1 -i sample%d.png -s 320x240 -aspect 4:3 output.flv
Run Code Online (Sandbox Code Playgroud)
这对我来说很好!
现在我正在尝试使用上面的命令来运行java代码.
如何使用Runtime.getRuntime()我的java代码运行ffmpeg命令.
请分享你的想法..
我正在开发基于Spring的应用程序.XML很简单,但包含几个几乎相同的片段.例如,我有5个不同的DAO对象,2个队列等.每个DAO的配置如下所示:
<bean id="deviceDaoTarget" class="com.mycompany.dao.hibernate.DeviceDAOHibernateImpl"
autowire="byName" />
<bean id="deviceDAO" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.mycompany.dao.DeviceDAO</value>
</property>
<property name="interceptorNames">
<list>
<value>hibernateInterceptor</value>
<value>deviceDaoTarget</value>
</list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
我很乐意使用某种带参数的导入.例如,我想像这样创建DAO的参数化配置:
<bean id="${dao.target}" class="${dao.class}"
autowire="byName" />
<bean id="deviceDAO" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>${dao.interface}</value>
</property>
<property name="interceptorNames">
<list>
<value>hibernateInterceptor</value>
<value>${dao.target}</value>
</list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
然后使用不同的参数多次调用它,例如:
<import resource="spring-dao.xml">
<param name="dao.interface">com.mycompany.dao.hibernate.DeviceDAO</param>
<param name="dao.class">com.mycompany.dao.hibernate.DeviceDAOHibernateImpl</param>
<param name="dao.target">deviceDaoTarget</param>
</import>
Run Code Online (Sandbox Code Playgroud)
这样的事情可能吗?
我想知道是否有可能获得有关我的maven项目的所有第一级依赖项的信息.我需要以下信息:名称,供应商,版本,许可证类型,参考URL,描述.所有这些信息都存储在每个包的pom.xml中.问题是我们有大约20个项目的层次结构,这些项目有数百个依赖项不断被更改.
我知道maven依赖插件.我mvn dependency:list使用greps和seds的组合运行并提取了包列表.但我需要许可证信息和URL.我可以实现自己的解析器,解析pom.xml以获取有趣的包并提取这些信息,但似乎应该存在可以使用的东西.
每当我键入此代码时,java 总是在类声明语句下加下划线,错误消息是“此处需要接口”。我怎样才能解决这个问题?
package tempconverter;
import javax.swing.*;
import java.awt.event.*;
import java.awt.FlowLayout;
import static java.lang.System.out;
public class TempConverter extends JFrame implements ActionListener, ActionEvent{
static JFrame f = new JFrame();
static JTextField enter = new JTextField(3);
static JButton confirm = new JButton("Convert");
public static void main(String[] args) {
f.setLayout(new FlowLayout());
f.setSize(100, 50);
f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(enter);
f.add(confirm);
f.setVisible(true);
}
@Override
public void actionPerformed (ActionEvent e) {
double toConvert = Float.parseFloat(enter.getText());
double inF, inK;
inF = toConvert / 5 * 9 + 32;
inK = …Run Code Online (Sandbox Code Playgroud) 我必须将一个简单的整数到字符串映射序列化为JSON,然后将其读回.序列化非常简单,但由于JSON键必须是字符串,因此生成的JSON如下所示:
{
"123" : "hello",
"456" : "bye",
}
Run Code Online (Sandbox Code Playgroud)
当我使用以下代码阅读它时:
new ObjectMapper().readValue(json, Map.class)
Run Code Online (Sandbox Code Playgroud)
我得到的Map<String, String>不是Map<Integer, String>我需要的.
我尝试添加密钥反序列化器如下:
Map<Integer, String> map1 = new HashMap<>();
map1.put(1, "foo");
map1.put(2, "bar");
ObjectMapper mapper = new ObjectMapper();
SimpleModule module = new SimpleModule();
module.addKeyDeserializer(Integer.class, new KeyDeserializer() {
@Override
public Object deserializeKey(String key, DeserializationContext ctxt) throws IOException, JsonProcessingException {
System.out.println("deserialize " + key);
return Integer.parseInt(key);
}
});
mapper.registerModule(module);
String json = mapper.writeValueAsString(map1);
Map map2 = mapper.readValue(json, Map.class);
System.out.println(map2);
System.out.println(map2.keySet().iterator().next().getClass());
Run Code Online (Sandbox Code Playgroud)
不幸的是我的密钥deserialzier永远不会被调用,map2事实上Map<String, …
Spring 3.0增加了很多兼容java 5的功能.现在许多方法都是参数化的.例如HibernateTemplate.executeXXX(),HibernateTemplate.getXXX(),HibernateTemplate.mergeXXX()返回T,
HibernateTemplate.loadAll()回报List<T>.
但是findXXX()方法很简单List,所以我必须把它转换成类似的东西List<MyEntity>.
有人知道是什么原因吗?为什么查找方法没有参数化?或者可能还有其他的参数化API?
这就是我在做什么.
这是spring.xml的相关部分:
<bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor" autowire="byName" /><!--sessionFactory will get autowired-->
<bean id="deviceDaoTarget" class="com.nso.solution.dao.DeviceDAOHibernateImpl" autowire="byName" /><!--sessionFactory will get autowired-->
<bean id="discoveryDAO" class="org.springframework.aop.framework.ProxyFactoryBean">
<property name="proxyInterfaces">
<value>com.nso.solution.dao.DeviceDAO</value>
</property>
<property name="interceptorNames">
<list>
<value>hibernateInterceptor</value>
<value>deviceDaoTarget</value>
</list>
</property>
</bean>
Run Code Online (Sandbox Code Playgroud)
DeviceDAO是一个接口,包含几个允许检索,保存和删除对象的方法.DeviceDAOHibernateImpl实现此接口,例如
public List<Device> getAllDevices() {
return getHibernateTemplate().loadAll(Device.class);
}
Run Code Online (Sandbox Code Playgroud)
我必须使用@SuppressWarnings("unchecked")注释来标记此方法.
我目前已经实现了一个java swing应用程序.在该应用程序中,我使用java.util.logging将事物记录到文本文件中.但由于文件非常大,因此很难通过文本文件.
所以我想将日志信息存储到oracle数据库(我用于应用程序)并提供swing接口来访问该表.因此,我将能够在该表中搜索某些日志记录级别,如INFO和SEVERE.有没有办法使用java util包或使用Log4j.请帮忙
package com.cordys.report;
import java.io.FileInputStream;
import org.apache.commons.codec.binary.Base64;
public class Encode {
public static String encodeFileStream(String filePath) //file path ex : C:\Program Files\Cordys\Web\reports\I0001180.pdf
{
try {
FileInputStream fin = new FileInputStream("E:/CSS Document/Test.pdf");
StringBuffer sb=new StringBuffer();
int lineLength = 72;
byte[] buf = new byte[lineLength/4*3];
while (true) {
int len = fin.read(buf);
if (len <= 0) {
break;
}
sb.append(Base64.encode(buf));
return sb.toString();
}
}
catch(Exception e) {
return e.getMessage();
}
}
}
Run Code Online (Sandbox Code Playgroud) 我没有使用CQL删除列.这是我收到的错误消息:
Bad Request: line 1:28 no viable alternative at input 'drop'
这就是我在做的事情.我正在运行cassandra 1.2.6.这是我创建键空间的方式:
CREATE KEYSPACE ex1 WITH replication = {
'class': 'SimpleStrategy',
'replication_factor': '1'
};
Run Code Online (Sandbox Code Playgroud)
然后我切换到刚创建的密钥空间:
use ex1
之后我创建了下表:
create table person ( id varchar, firstName varchar, lastName varchar, primary key (id));
Run Code Online (Sandbox Code Playgroud)
现在我尝试删除一列,如下所示:
cqlsh:ex1> alter table person drop lastName;
Bad Request: line 1:19 no viable alternative at input 'drop'
Run Code Online (Sandbox Code Playgroud)
尝试使用关键字COLUMNFAMILY而TABLE不是帮助.
我究竟做错了什么?
我正在努力自学java,在使用类编写代码时遇到了这个错误
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Unknown Source)
at java.util.Scanner.next(Unknown Source)
at java.util.Scanner.nextDouble(Unknown Source)
at StateCalculator.getOperand(StateCalculator.java:29)
at StateCalculator.main(StateCalculator.java:77)
Run Code Online (Sandbox Code Playgroud)
以下是我的代码:
import java.util.Scanner;
public class StateCalculator {
private double currentValue = 0;
//Initialize to 0
public StateCalculator() {
}
public static int displayMenu() {
Scanner keyboard = new Scanner(System.in);
int menuChoice = 0;
do {
System.out.print("Menu\n 1. Add\n 2. Subtract\n 3. Multiply\n 4. Divide\n 5.Clear\n 6. Quit\n What would you like to do?: ");
menuChoice = keyboard.nextInt();
} while(menuChoice < 1 …Run Code Online (Sandbox Code Playgroud)