我有一个我想用Java读取的2 GB文件(实际上是4个2gb文件).所以Java 7中有一个新功能可以让我一次读取所有字节.
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.StandardOpenOption;
public class reconstructor {
public static void main(String[] args) throws IOException {
Path p = Paths.get("test.txt");
for (int i = 0; i < 1; i++) {
byte[] b = Files.readAllBytes(p);
Files.write(p, b, StandardOpenOption.APPEND);
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是一个愚蠢的程序,它将读取一个预先输入单个字节的文件并连续读取该文件并将其读回的内容附加到同一文件中.现在显然,RAM不够大,一次读取2gb文件,更不用说其中四个,所以我想知道是否有任何快速方法,不使用外部库(除非这是唯一的方法)阅读四文件逐字节,以便RAM不会过载(否则我最终会出现Java堆错误).
我收到此语法错误消息:
/usr/src/check_in/lib/check_in.rb:105:语法错误,意外的keyword_end,期待'}'
class CheckIn < Adhearsion::CallController
def run
answer
#play 'welcome.wav' # "Welcome to the PSG check in application."
logger.info "#{call.from.to_s} called at #{time.now.to_s}"
if verify_phone(call.from) == false # If it's not a site phone
logger.info "Number not recognised, routing to Ops"
#play 'not_site_phone.wav' # "Number not recognized."
#dial(sip:number) # Dial operations
hangup
else
user = verify_uid # Checks the User Id
end
if to_check_out?(user.uid)
check_out(user.uid)
else
update_shift(user.uid)
#play 'thank_you.wav'
end
end
def verify_uid
count = 1 # Generic count …Run Code Online (Sandbox Code Playgroud) 鉴于此方法:
public void OutputWrite (BigInteger[] EncryptCodes) throws FileNotFoundException{
JFileChooser chooser = new JFileChooser();
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.showSaveDialog(null);
String path = chooser.getSelectedFile().getAbsolutePath();
PrintWriter file = new PrintWriter(new File(path+"EncryptedMessage.txt"));
for (int i = 0; i <EncryptCodes.length; i++) {
file.write(EncryptCodes[i]+ " \r\n");
}
file.close();
}
Run Code Online (Sandbox Code Playgroud)
忽略变量名称,此方法的作用是写入EncryptCodes在项目文件夹中生成的txt文件中的数据EncryptedMessage.txt.
我需要的是一种方法来保存该txt文件而不是项目文件夹,以便在运行期间保存在用户指定的位置(打开另存为对话框).我认为它可以由JFilechooser完成,但我不能让它工作.
如何在子构造函数之前运行父构造函数?(代码:)
class database{
public function __construct(){
// Connect to database
}
}
class child extends database{
public function __construct(){
// Do something
}
}
Run Code Online (Sandbox Code Playgroud)
我希望它连接到数据库,然后运行子的构造函数,这可能吗?
为什么是Math.ceil(15/10)1.0而不是2.0?当我跑步时,我Math.ceil((double)15/10)按预期得到2.0.
我想随着时间的推移改变图像的透明度,而且我用的方法这样做drawImage()的java.awt.Graphics.我知道网上有很多关于如何做到这一点的不同答案,但我找不到一个足以让我理解和实施的答案.
我只想说我有一个BufferedImage图像,我想以50%的不透明度绘制这个图像.我如何初始化,image以及在绘制图像时如何调整图像的alpha级别.如果我可以使用该方法drawImage()并使用该方法来改变图像的透明度,那将是很好的,但它可能不那么简单.
我目前正在使用Unity3D引擎开发游戏.我们需要用a Curve Editor来描述给定法术伤害的等级.已经有一个Curve Editor类,在Unity3D引擎的C#程序集中具有所需的功能,但它无法访问.我尝试通过Reflection实例化该类型的对象.但是我遇到了一个问题.这个类的构造函数需要一些参数1,其中1个恰好是另一个不可访问的类的数组.这就是问题所在.我能够通过反射构造一个对象,但不能构造该类型的对象数组.这是构造函数:
public CurveEditor(Rect rect, CurveWrapper[] curves, bool minimalGUI){...}
Run Code Online (Sandbox Code Playgroud)
我能够构造一个CurveWrapper对象Reflection,但不是整个数组.我试图创建Object[]数组并CurveWrapper在里面放几个对象但是当我通过反射将这个数组传递给构造函数时,我得到了无效的参数异常.
任何人都能协助我这个吗?
我有一个 3 层画布,我给每个画布一个单独的 id。
这就是我正在做的。
HTML
<div style="position:relative;">
<canvas id="layer1" style="position: absolute; left: 0; top: 0; z-index: 0;">
</canvas>
<canvas id="layer2" style="position: absolute; left: 0; top: 0; z-index: 1;">
</canvas>
<canvas id="layer3" style="position: absolute; left: 0; top: 0; z-index: 1;">
</canvas>
</div>
Run Code Online (Sandbox Code Playgroud)
我可以在 layer1 上绘制图像
JS
var canvas = document.getElementById('layer1');
var context = canvas.getContext('2d');
context.canvas.width = window.innerWidth;
context.canvas.height = window.innerHeight*0.7;
var imageObj = new Image();
var imageObj1 = new Image();
imageObj.onload = function() {
context.drawImage(imageObj, 0, 0,context.canvas.width,context.canvas.height*0.9);
context.drawImage(imageObj1, x1, y1,6,canvasHeight); …Run Code Online (Sandbox Code Playgroud) 我想使用单个pom.xml在maven中运行多个命令提示符命令.我怎样才能做到这一点?
例如:我有2个命令要执行.我正在使用执行第一个命令exec-maven-plugin.下面是我的pom.xml执行第一个命令的部分:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<id>load files</id>
<phase>install</phase>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>windchill</executable>
<arguments>
<argument>wt.load.LoadFileSet</argument>
<argument>-file</argument>
<argument>${basedir}/fileSet.xml</argument>
<argument>-UNATTENDED</argument>
<argument>-NOSERVERSTOP</argument>
<argument>-u</argument>
<argument>wcadmin</argument>
<argument>-p</argument>
<argument>wcadmin</argument>
</arguments>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
为此,构建是成功的.是否可以在同一个pom.xml中执行另外一个命令?我无法做到这一点.所以有人请帮助如何在pom.xml中添加它
java ×4
file ×2
html ×2
alpha ×1
c# ×1
canvas ×1
casting ×1
double ×1
drawimage ×1
graphics ×1
html5-canvas ×1
input ×1
io ×1
java-7 ×1
javascript ×1
jfilechooser ×1
maven ×1
php ×1
reflection ×1
ruby ×1
swing ×1
syntax-error ×1