Delphi Dll函数中的Java JNA映射

如何使用JNA映射此function: Delphi Dllfunction代码: function send_command (const command : byte; var size : byte; var data : pbyte) : integer; stdcall external ‘comunication.dll’; 使用Delphi示例程序中的示例: send_command(cmdCLOCK_ADJUST,tam,pb); 哪里: const cmdCLOCK_ADJUST = $18; var tam : byte; pb, p : pbyte; begin … tam = 7; p:= pb; for i:= 1 to tam do begin p^:= Dados [i]; inc […]

使用CustomAdapter更改ListView的显示方式

我想用于自定义适配器的XML: 我的列表视图XML布局: 我的Java代码: package com.test.testing; import java.io.File; import java.util.ArrayList; import java.util.Date; import android.app.Fragment; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.graphics.Color; import android.os.Bundle; import android.os.Environment; import android.text.Editable; import android.text.TextWatcher; import android.text.format.DateFormat; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.InputMethodManager; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; import android.widget.RadioGroup; import android.widget.RadioGroup.OnCheckedChangeListener; import android.widget.RelativeLayout; […]

如何强制Joda-Time只解析String的一部分?

我假设我有以下日期(在String中): 2009-05-15T23:00:00 2009-05-15T23:00:00.000Z 2009-05-15 我不关心时间和区域,只有日期与我相关。 所以我想尝试用以下模式解析它: YYYY-MM-DD 我尝试使用Joda-Time解析它: DateTimeFormat = DateTimeFormat.forPattern(“yyyy-MM-dd”); format.withZone(zone).parseDateTime(string).toLocalDate(); 我得到以下exception: java.lang.IllegalArgumentException: Invalid format: “2009-05-15T23:00:00.000Z” is malformed at “T23:00:00.000Z” 有没有办法如何强制Joda-Time忽略其余的字符串?

使用MultithreadMapper替换Mapper时,键入地图中的键不匹配

我想为MapReduce作业实现一个MultithreadMapper。 为此,我在一个工作代码中用MultithreadMapper替换了Mapper。 这是我得到的例外: java.io.IOException: Type mismatch in key from map: expected org.apache.hadoop.io.IntWritable, recieved org.apache.hadoop.io.LongWritable at org.apache.hadoop.mapred.MapTask$MapOutputBuffer.collect(MapTask.java:862) at org.apache.hadoop.mapred.MapTask$NewOutputCollector.write(MapTask.java:549) at org.apache.hadoop.mapreduce.TaskInputOutputContext.write(TaskInputOutputContext.java:80) at org.apache.hadoop.mapreduce.lib.map.MultithreadedMapper$SubMapRecordWriter.write(MultithreadedMapper.java:211) at org.apache.hadoop.mapreduce.TaskInputOutputContext.write(TaskInputOutputContext.java:80) at org.apache.hadoop.mapreduce.Mapper.map(Mapper.java:124) at org.apache.hadoop.mapreduce.Mapper.run(Mapper.java:144) at org.apache.hadoop.mapreduce.lib.map.MultithreadedMapper$MapRunner.run(MultithreadedMapper.java:264) 这是代码设置: public static void main(String[] args) { try { if (args.length != 2) { System.err.println(“Usage: MapReduceMain “); System.exit(123); } Job job = new Job(); job.setJarByClass(MapReduceMain.class); […]

@Injection不适用于CDI bean

我有一个CDI bean,我正在使用@ConversationScoped。 当我尝试为对话对象执行@Inject时,我得到一个NPE。 @ConversationScoped @Named(“customerbean”) public class CustomerBean implements Serializable { @Inject private Conversation conversation; private static final EntityManagerFactory emf = Persistence.createEntityManagerFactory(“ba”); private EntityManager em; private Customer customer; boolean disabled; public CustomerBean() { beginConversation(); customer = new Customer(); em = emf.createEntityManager(); disabled = false; } private void beginConversation() { if (this.conversation.isTransient()) { this.conversation.begin(); return; } […]

同步以确保另一个线程将看到对不可变对象的引用

我正在研究这个,以了解新JMM中最终字段的行为(5以后)。 这个概念很清楚:在正确构造对象之后,保证初始化的最终字段对所有线程的可见性。 但是在本节的最后,我读到了这个,这让我感到困惑: 现在,说完所有这些,如果在一个线程构造一个不可变对象(即一个只包含最终字段的对象)之后,你想确保所有其他线程都能正确看到它,你通常还需要使用同步。 例如,没有其他方法可以确保第二个线程可以看到对不可变对象的引用。 这是否意味着虽然单个最终字段(组成不可变对象)没有同步(例如,此处可见性)问题。 但是,在线程中首次创建的不可变对象本身在其他线程中可能不可见(正确创建)? 如果是这样,虽然我们可以跨线程共享初始化的不可变对象而没有任何线程不安全的担忧,但在创建时,他们需要“特别关注”线程安全,就像其他可变项一样?

取消并重新启动CountDownTimer问题

嗨我有一个CountDownTimer函数的问题 首先,我可以使用counter.cancel()来停止倒计时; 然后我将milliUntilFinished值存储在countercur中。 然后我使用存储的countercur值重新启动计时器。 一切正常。 但是当我试图取消第二次时,它再也不会停止计时器了。 只运作一次,我错过了什么? 这是我的代码谢谢: // Main code : MyCount counter = new MyCount(59000, 1000); counter.start(); // start timer at 59 seconds /// button1.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { counter.cancel(); // — > cancelling the timer works here, the clock stops ok // // rest of code snipped button2.setOnClickListener(new View.OnClickListener() […]

maven默认filter目录的好处

最近我发现了maven资源过滤,并在文档中看到了一个注释: 标准目录布局 src / main / filters资源filter文件 我注意到maven默认情况下不搜索此目录中标签中声明的文件。 那么在这种情况下坚持使用Maven布局有什么好处(除了结构均匀性)?

我应该使用View Holder图案作为我的适配器吗?

当我创建一个类extends BaseAdapter ,我收到一条警告消息 Unconditional layout inflation from view adapter: Should use View Holder pattern (use recycled view passed into this method as the second parameter) for smoother scrolling 我是否需要像这个建议一样更改我的代码? 我的所有代码都运行得很顺利,是否有necessary更改代码以使用最新样式执行updata代码? 或者只需要添加@SuppressLint({ “ViewHolder”, “InflateParams” }) ? 我的适配器 public View getView(int position, View convertView, ViewGroup parent) { View v = inflater.inflate(R.layout.list_item, null); TextView merchant_type = (TextView) v.findViewById(R.id.merchant_type); […]

Spring security oauth2 – 无法访问/ oauth / token路由

我刚刚开始通过以下教程为我的其他api创建一个身份validation服务器: https : //jugbd.org/2017/09/19/implementing-oauth2-spring-boot-spring-security/ 。 一切顺利,直到最后我无法访问/ oauth / token路由以进行身份​​validation。 我想我需要更多的解释才能完全理解这种认证。 谢谢你,Matthieu Meunier PS:这是我的课程: ResourceServerConfig.java @Configuration @EnableResourceServer public class ResourceServerConfig extends ResourceServerConfigurerAdapter { @Override public void configure(HttpSecurity http) throws Exception { http.authorizeRequests() .antMatchers(“/”).permitAll() .antMatchers(“/api/secure/**”).authenticated(); } } AuthorizationServerConfig.java @Configuration @EnableAuthorizationServer public class AuthorizationServerConfig extends AuthorizationServerConfigurerAdapter { @Autowired private AuthenticationManager authenticationManager; @Override public void configure(AuthorizationServerSecurityConfigurer serverSecurityConfigurer){ serverSecurityConfigurer .tokenKeyAccess(“permitAll()”) […]