根据java文档,在任何java.io Streams上调用close()会自动调用flush().但是我已经在很多例子中看到过,即使在生产代码中,开发人员在close()之前也明确地使用了flush().在什么条件下我们需要在close()之前使用flush()?
我试图找到将InputStream传递给OutputStream的最佳方法.我没有选择使用任何其他库,如Apache IO.这是片段和输出.
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.channels.FileChannel;
public class Pipe {
public static void main(String[] args) throws Exception {
for(PipeTestCase testCase : testCases) {
System.out.println(testCase.getApproach());
InputStream is = new FileInputStream("D:\\in\\lft_.txt");
OutputStream os = new FileOutputStream("D:\\in\\out.txt");
long start = System.currentTimeMillis();
testCase.pipe(is, os);
long end = System.currentTimeMillis();
System.out.println("Execution Time = " + (end - start) + " millis");
System.out.println("============================================");
is.close();
os.close();
}
}
private static PipeTestCase[] testCases = {
new PipeTestCase("Fixed Buffer Read") {
@Override …
Run Code Online (Sandbox Code Playgroud) 如何verbose_name
在其管理模块中访问模型?如果我们有一个如下所示的模型实例,我们可以访问相同的内容.
instance._meta.verbose_name.title()
Run Code Online (Sandbox Code Playgroud) 命令:
\eclipse-SDK-4.2RC3-win32-x86_64_001\eclipse\plugins>java -jar org.eclipse.osgi_3.8.0.v20120529-1548.jar -console
Run Code Online (Sandbox Code Playgroud)
异常(来自日志文件)
!SESSION 2012-06-22 23:36:27.649 -----------------------------------------------
eclipse.buildId=unknown
java.version=1.6.0_25
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Command-line arguments: -console
!ENTRY org.eclipse.osgi 4 0 2012-06-22 23:36:28.632
!MESSAGE Could not find bundle: org.eclipse.equinox.console
!STACK 0
org.osgi.framework.BundleException: Could not find bundle: org.eclipse.equinox.console
at org.eclipse.osgi.framework.internal.core.ConsoleManager.checkForConsoleBundle(ConsoleManager.java:211)
at org.eclipse.core.runtime.adaptor.EclipseStarter.startup(EclipseStarter.java:297)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:176)
at org.eclipse.core.runtime.adaptor.EclipseStarter.main(EclipseStarter.java:151)
!ENTRY org.eclipse.osgi 4 0 2012-06-22 23:36:28.663
!MESSAGE Application error
!STACK 1
java.lang.IllegalStateException: Unable to acquire application service. Ensure that the org.eclipse.core.runtime bundle is resolved and started (see config.ini). …
Run Code Online (Sandbox Code Playgroud) 在Django管理界面中,是否可以排除Inline中的一些字段?
在覆盖特定模型的save()方法时,是否可以确定它是新记录还是更新?
我试图从Python 2.7.10 64位Windows版本的源代码编译pycrypto-2.6.1并面临以下错误.
Processing pycrypto-2.6.1.tar.gz
Writing c:\users\sivasuba\appdata\local\temp\easy_install-ecznz_\pycrypto-2.6.1\setup.cfg
Running pycrypto-2.6.1\setup.py -q bdist_egg --dist-dir c:\users\sivasuba\appdata\local\temp\easy_install-ecznz_\pycrypto-2.6.1\egg-dist-tmp-us3gka
warning: GMP or MPIR library not found; Not building Crypto.PublicKey._fastmath.
winrand.c
LINK : fatal error LNK1104: cannot open file 'python27.lib'
error: Setup script exited with error: command 'C:\\Users\\sivasuba\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\VC\\Bin\\amd64\\link.exe' failed with exit status 1104
Run Code Online (Sandbox Code Playgroud)
谷歌搜索没有多大帮助.任何有关这方面的帮助将不胜感激.
PS我不是在寻找预先编译的二进制文件.要求是从源代码构建它.
python中的any命令行选项是否打印异常/错误类层次结构?
输出应类似于http://docs.python.org/2/library/exceptions.html#exception-hierarchy
是否可以动态地为forms.FileField()提供初始值?
django ×4
java ×3
django-admin ×2
python ×2
class ×1
django-forms ×1
exception ×1
iostream ×1
java-io ×1
javascript ×1
osgi ×1
pipe ×1
pycrypto ×1
python-2.7 ×1