我使用eclipse作为IDE.当我右键单击项目然后单击maven更新我的java版本更改为1.5.这是我到目前为止所做的,我按照这里列出的所有步骤
<build>
<plugins>
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>9.1.3.v20140225</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugin</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
Run Code Online (Sandbox Code Playgroud)
毕竟当我点击"Maven update"时,我的java版本会自动更改为1.5.同样在上述步骤中,前两步的版本也会自动更改为1.5.我怎样才能解决这个问题?
我有一些服务器代码在上传图像时生成缩略图.问题在于,当拍摄图像并旋转相机/设备时,即使在任何图像查看软件中以正确的方向显示全尺寸图像本身,也会旋转缩略图.这只发生在jpgs上.
在OSX上使用Preview,我可以看到jpgs中嵌入了方向元数据.当我使用ImageTools(Grails插件)生成缩略图时,EXIF元数据不在缩略图中,这就是缩略图显示为旋转的原因.
通过离线对话,我了解到虽然读取EXIF元数据相对容易,但没有简单的方法来编写它,这就是生成jpg缩略图时数据丢失的原因.
所以看来我有两个选择:
有没有人知道其他任何选择?
如何在Java中的long的特定位置设置/取消位?
例如,
long l = 0b001100L ; // bit representation
Run Code Online (Sandbox Code Playgroud)
我想在位置2处设置位并在位置3处取消设置位,因此相应的长度将是,
long l = 0b001010L ; // bit representation
Run Code Online (Sandbox Code Playgroud)
任何人都可以帮我怎么做?
我对变量名和方法名中使用下划线(命名约定)_作为起始字母感到困惑.例如_sampleVariable和_getUserContext().任何人都可以澄清何时使用它?
我继续学习java 8.
我发现了有趣的行为:
让我们看看代码示例:
// identity value and accumulator and combiner
Integer summaryAge = Person.getPersons().stream()
//.parallel() //will return surprising result
.reduce(1, (intermediateResult, p) -> intermediateResult + p.age,
(ir1, ir2) -> ir1 + ir2);
System.out.println(summaryAge);
Run Code Online (Sandbox Code Playgroud)
和模型类:
public class Person {
String name;
Integer age;
///...
public static Collection<Person> getPersons() {
List<Person> persons = new ArrayList<>();
persons.add(new Person("Vasya", 12));
persons.add(new Person("Petya", 32));
persons.add(new Person("Serj", 10));
persons.add(new Person("Onotole", 18));
return persons;
}
}
Run Code Online (Sandbox Code Playgroud)
12 + 32 + 10 + 18 = 72
对于序列流,此代码始终返回73(72 …
所以我实际上是在尝试使用TypedByteArray作为我的身体进行PUT.我正在与Azure服务器进行交互,因此第一步是
使用我的图像元数据进行POST调用,然后返回一个URL(例如URL_PUT)
我必须向该URL_PUT发出PUT请求(从步骤1开始),所以我的改进单例接口函数如下所示:
public interface ImageInterface {
@PUT("/{nothing}")
Response uploadBlob(@Body TypedByteArray byteArray,
@Header("Content-Length") String byteArrayLength,
@Path(value="nothing",encode=false) String nothing);
}
Run Code Online (Sandbox Code Playgroud)
但我得到一个错误,说当我通过""时,URL路径必须以"/"开头.对于上面的函数我尝试传递一个空字符串,但无济于事.
所以基本上我只想使用端点进行改造,但PUT没有路径/ balnk路径.有没有办法做到这一点?
我读到自Java 7以来,在第一个语句中创建右侧指定类型的集合是不好的样式,因为编译器可以从左侧推断出类型.
List<Integer> myList = new ArrayList<Integer>();
Run Code Online (Sandbox Code Playgroud)
我的问题是,当像这样初始化列表时,编译器找不到类型,我得到一个未经检查的类型警告:
List<Integer> myList = new ArrayList();
Run Code Online (Sandbox Code Playgroud) 我需要通过Python访问Windows平板电脑笔数据(例如表面)。我主要需要位置、压力和倾斜值。
我知道如何访问 Wacom 笔数据,但 Windows 笔不同。
有一个名为Kivy的 Python 库的 Python 库可以处理多点触控,但它会将我的笔识别为手指 (WM_TOUCH),而不是笔 (WM_PEN)。
这是我的 Kivy 代码(不报告压力和倾斜):
from kivy.app import App
from kivy.uix.widget import Widget
class TouchInput(Widget):
def on_touch_down(self, touch):
print(touch)
def on_touch_move(self, touch):
print(touch)
def on_touch_up(self, touch):
print("RELEASED!",touch)
class SimpleKivy4(App):
def build(self):
return TouchInput()
Run Code Online (Sandbox Code Playgroud)
有一个名为Tablet 的出色处理库,它仅适用于具有简单 API 的 Wacom 数位板(例如,tablet.getPressure())
我需要这样的东西。
我想编写代码来下载一个存储在我系统中的文件
这是我的代码:
在控制器类中,我有以下映射
@RequestMapping(value = "/processFile", method = RequestMethod.POST)
public @ResponseBody ModelAndView downloadFileProcess(
@RequestParam("file") File originalFile,
@RequestParam("action") String action, HttpServletResponse response) {
ModelAndView model = new ModelAndView();
model.setViewName("error");
System.out.println("");
System.out.println("Action: "+action);
model.addObject("message", "Action:" + action);
try {
utility.downloadFile(originalFile, response);
message = "The file was downloaded successfully";
} catch (IOException e) {
e.printStackTrace();
message = "The process failed due to following reason: "
+ e.getMessage();
} catch (Exception e) {
e.printStackTrace();
message = "The process failed due to following reason: " …Run Code Online (Sandbox Code Playgroud) 我在Java中看到,可以创建一个Class泛型和一个泛型方法.我还看到了使构造函数与Class一起通用的代码.我可以只使构造函数通用吗?如果是,如何调用构造函数?
java ×8
android ×1
eclipse ×1
generics ×1
groovy ×1
http ×1
java-8 ×1
java-stream ×1
maven ×1
python ×1
reduce ×1
retrofit ×1
spring-boot ×1
spring-mvc ×1
stylus-pen ×1
surface ×1
tablet ×1
variables ×1