以前我们的Web应用程序中有一些zip文件.我们希望在zip文件中削减特定的文本文档.这不是问题:
URL url = getClass().getResource(zipfile);
ZipFile zip = new ZipFile(url.getFile().replaceAll("%20", " "));
Entry entry = zip.getEntry("file.txt");
InputStream is = zip.getInputStream(entry);
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String line = reader.readLine();
while (line != null) {
// do stuff
}
Run Code Online (Sandbox Code Playgroud)
但是我们已经将这些zip文件移动到另一个模块中,并希望将它们打包到jar中.不幸的是,创建ZipFile现在失败了.我可以获得一个InputStreamzip:但我无法获得条目本身的输入流.
InputStream is = getClass().getResourceAsStream(zipfile);
ZipInputStream zis = new ZipInputStream(is);
ZipEntry entry = zis.getNextEntry();
while (entry != null && !entry.getName().equals("file.txt")) {
entry = zis.getNextEntry();
}
Run Code Online (Sandbox Code Playgroud)
但我无法获得条目本身的输入流.我尝试找到条目的长度并从中获取下一个n字节,ZipInputStream但这对我不起作用.似乎读取的所有字节都是0.
有没有办法解决这个问题,还是我必须将zip文件移回核心项目?
可能重复:
如何递归列出C#中目录中的所有文件?
我想列出给定文件夹(路径)的文件和文件夹的"子路径"
假设我有文件夹C:\ files\folder1\subfolder1\file.txt
如果我给函数c:\ files\folder1 \
我将获得subfolder1子文件夹1\file.txt
当srciframe的更改时,如何运行函数?iframe显示的网站不在我的服务器上...当用户点击或按下iframe内的按钮时,我想执行一个功能来测试是否src已更改...
在这种情况下我是否必须担心字节顺序(整数必须是0-127):
int a = 120;
int b = 100;
int c = 50;
char theBytes[] = {a, b, c};
Run Code Online (Sandbox Code Playgroud)
I think that, since each integer sits in its own byte, I don't have to worry about Endianess in passing the byte array between systems. This has also worked out empirically. Am I missing something?
_data is a byte[] array of Attachment data.
When I'm doing this:
var ms = new MemoryStream(_data.Length);
ms.Write(_data,0,_data.Length);
mailMessage.Attachments.Add(new Attachment(ms, attachment.Name));
Run Code Online (Sandbox Code Playgroud)
Attachment comes empty. Actually outlook shows the filesize but it's incorrect.
Well, I thought there is a problem in my _data. Then I decided to try this approach:
var ms = new MemoryStream(_data.Length);
ms.Write(_data,0,_data.Length);
fs = new FileStream(@"c:\Temp\"+attachment.Name,FileMode.CreateNew);
fs.Write(ms.GetBuffer(), 0, ms.GetBuffer().Length);
fs.Flush();
fs.Close();
mailMessage.Attachments.Add(new Attachment(@"c:\Temp\" + attachment.Name));
Run Code Online (Sandbox Code Playgroud)
And that works. What's wrong with the first one?
我有以下方法:
var catIds = DetachedCriteria.For<Category>()
.Add<Category>(c => c.TypeCode == "IMA")
.SetProjection(LambdaProjection.Property<Category>(s => s.Id));
Run Code Online (Sandbox Code Playgroud)
这没有返回任何内容,因为在数据库中该字段是nchar(10).我想要Trim()TypeCode值,如下所示:
var catIds = DetachedCriteria.For<Category>()
.Add<Category>(c => c.TypeCode.Trim() == "IMA")
.SetProjection(LambdaProjection.Property<Category>(s => s.Id));
Run Code Online (Sandbox Code Playgroud)
但它返回NHibernate错误:
Unrecognised method call in epression c.TypeCode.Trim()
Run Code Online (Sandbox Code Playgroud)
办公室里的其中一个人认为这是因为HHibernate不知道如何转换.Trim()为SQL(或者那些沿着这些方向的东西).任何人都可以建议我如何解决这个问题?
我必须承认我不是SAP R/3编程方面的专家,因此这更像是一个基本问题.
有没有办法在SAP系统上获取可访问的RFC模块和/或表的列表?在互联网上的许多例子中,我发现了一个似乎可以在每个SAP系统上使用的RFC模块("SD_RFC_CUSTOMER_GET"),我想知道是否还有更多这些标准RFC模块可以使用.我可以轻松地在SAP系统中查询所有可用的SAP查询,但我找不到使用RFC模块或表格执行此操作的方法.在Google上搜索了几个小时之后,我甚至找不到这些RFC模块的列表...所以我错过了一些东西或者这是不可能的?
在此先感谢您的帮助.
这可能吗?我尝试过,EasyMock.expectLastCall().times(0);但EasyMock抱怨时间必须> = 1
我正在尝试在ubuntu 10.04上使用s3cmd与本地文件夹同步.这非常适合将本地驱动器中的内容传送到S3.但是,我希望文件ACL是"公共的",但所有文件都没有它.
在我的.s3cfg文件中,我设置:
acl_public = True
Run Code Online (Sandbox Code Playgroud)
我试过了:
s3cmd sync -P --delete-removed "$TARGETFOLDER" "s3://$BUCKET/"
Run Code Online (Sandbox Code Playgroud)
我也尝试过:
s3cmd sync --acl-public --delete-removed "$TARGETFOLDER" "s3://$BUCKET/"
Run Code Online (Sandbox Code Playgroud)
并且,对于踢,也试过这个:
s3cmd sync -P --acl-public --delete-removed "$TARGETFOLDER" "s3://$BUCKET/"
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
更新
我已将目标存储区上的ACL设置为经过身份验证的用户和管理员的"读/写/完全控制",并为Everyone设置了只读.
我似乎无法弄清楚为什么getProjection()返回的对象是未定义的.这是我的代码:
// Handles the completion of the rectangle
var ne = recBounds.getNorthEast();
var sw = recBounds.getSouthWest();
$("#map_tools_selat").attr( 'value', sw.lat() );
$("#map_tools_nwlat").attr( 'value', ne.lat() );
$("#map_tools_selng").attr( 'value', ne.lng() );
$("#map_tools_nwlng").attr( 'value', sw.lng() );
// Set Zoom Level
$("#map_tools_zoomlevel").attr( 'value', HAR.map.getZoom()+1 );
document.getElementById("map_tools_centerLat").value = HAR.map.getCenter().lat();
document.getElementById("map_tools_centerLong").value = HAR.map.getCenter().lng();
// All this junk below is for getting pixel coordinates for a lat/lng =/
MyOverlay.prototype = new google.maps.OverlayView();
MyOverlay.prototype.onAdd = function() { }
MyOverlay.prototype.onRemove = function() { }
MyOverlay.prototype.draw = function() { }
function …Run Code Online (Sandbox Code Playgroud) c# ×4
.net ×2
java ×2
abap ×1
amazon-s3 ×1
bapi ×1
easymock ×1
email ×1
endianness ×1
file ×1
filesystems ×1
google-maps ×1
html ×1
jar ×1
javascript ×1
nhibernate ×1
objective-c ×1
path ×1
sap ×1
trim ×1
ubuntu ×1
unit-testing ×1
zip ×1