当前位置:首页 » 操作系统 » linuxtostring

linuxtostring

发布时间: 2022-04-14 16:42:19

linux英文系统,星期一到星期天都是英文显示,有什么方式转换中文

更改环境变量LC_ALL, zh_CN, zh_CN.gb2312, zh_CN.utf8等中文locale
或者可以修改/etc/sysconfig/i18N中的LANG,彻底改成中文界面

❷ 用java如何读取linux中的某个文件

java是跨平台语言,在linux上读文件跟在windows上读文件是一样的 只是文件路径不一样,可以用File对象和FileInputSteam来读取。但要注意文件编码问题。
如果有中文请做适当的编码转换,通常情况下Linux的默认字符编码为UTF-8编码方式,项目可以直接采用utf8编码方式操作.用System.getProperty("file.encoding")可检查系统编码格式。可改操作系统的文件系统编码,vi /etc/profile,在文件末尾加上
export LANG="zh_CN.GBK"
export LC_ALL="zh_CN.GBK"
编码转换代码:new String(files[i].getName().getBytes("GBK"),"UTF-8");

文件操作的核心代码请参考下面代码:

String path= "/home/";
path= "/home/multiverse/Repository/PMEPGImport";
File file=new File(path);
File[] tempList = file.listFiles();
for (int i = 0; i < tempList.length; i++) {
if (tempList[i].isFile()) {
//FileInputStream fis = new FileInputStream("fileName");

//InputStreamReader isr = new InputStreamReader(fis,"utf-8");
StringBuffer buffer = new StringBuffer();
String text;

BufferedReader input = new BufferedReader (new FileReader(tempList[i]));

while((text = input.readLine()) != null)
buffer.append(text +"/n"); }

if (tempList[i].isDirectory()) {
System.out.println("文件夹:"+tempList[i]);
}
}

❸ linux ngettext什么用

String content=jtextarea1.getText().toString(); String[] a=string.split("\n"); 这样应该没问题,用\n不用\n\r是因为android是Unix内核,回车换行是\n

❹ java程序里如何调用linux命令

Java 可以通过 Runtime 调用Linux命令,形式如下:

  1. Runtime.getRuntime().exec(command)

    但是这样执行时没有任何输出,因为调用 Runtime.exec 方法将产生一个本地的进程,并返回一个Process子类的实例(注意:Runtime.getRuntime().exec(command)返回的是一个Process类的实例)该实例可用于控制进程或取得进程的相关信息。

  2. 由于调用 Runtime.exec 方法所创建的子进程没有自己的终端或控制台,因此该子进程的标准IO(如stdin,stdou,stderr)都通过 Process.getOutputStream(),Process.getInputStream(), Process.getErrorStream() 方法重定向给它的父进程了。

  3. 用户需要用这些stream来向子进程输入数据或获取子进程的输出,下面的代码可以取到 linux 命令的执行结果:

    try {

    String[] cmd = new String[]{”/bin/sh”, “-c”, ” ls “};

    Process ps = Runtime.getRuntime().exec(cmd);

    BufferedReader br = new BufferedReader(new InputStreamReader(ps.getInputStream()));

    StringBuffer sb = new StringBuffer();

    String line;

    while ((line = br.readLine()) != null) {

    sb.append(line).append(” ”);

    }

    String result = sb.toString();

    System.out.println(result);

    } catch (Exception e) {

    e.printStackTrace();

    }

❺ LINUX服务器如何跑ASP项目

利用mono+xsp架构asp.net环境,可以跑ASP项目
1、 安装准备(系统安装忽略)
#安装完CentOS后,首先更新系统
yum -y update
#然后安装相关的编译器和必备的软件
yum -y install bison pkgconfig glib2-devel gettext make libpng-devel libjpeg-devel libtiff-devel libexif-devel giflib-devel libX11-devel freetype-devel fontconfig-devel cairo-devel libtiff libtiff-devel libjpeg libjpeg-devel giflib giflib-devel libpng libpng-devel libX11 libX11-devel freetype freetype-devel fontconfig fontconfig-devel libexif libexif-devel libXft-devel ghostscript-devel gnome-doc-utils unzip
2 、下载安装所需要的软件包
统一下载到/usr/local/src下
wget http://download.mono-project.com/sources/libgdiplus/libgdiplus-2.10.tar.bz2
wget http://download.mono-project.com/sources/mono/mono-2.10.8.tar.bz2
wget http://download.mono-project.com/sources/xsp/xsp-2.10.tar.bz2
wget http://download.mono-project.com/sources/mod_mono/mod_mono-2.10.tar.bz2
wget http://apache.fayea.com/apache-mirror//httpd/httpd-2.2.27.tar.gz
3.安装libgdiplus
libgdiplus是mono中的System.Drawing依赖的一个组件,用于显示web页面基本颜色等。
cd /usr/local/src
tar -xjvf libgdiplus-2.10.tar.bz2
cd libgdiplus-2.10
./configure --prefix=/usr/local
make
make install
4.安装mono
cd /usr/local/src
tar -xjvf mono-2.10.8.tar.bz2
cd mono-2.10.8
./configure --prefix=/usr/local
make
make install
Mono安装完成之后,可以用命令mono -V查看一下mono的安装情况,如果能够看到mono版本号等信息,说明Mono安装成功。
5.安装apache
cd /usr/local/src
tar -zxvf httpd-2.2.27.tar.gz
cd httpd-2.2.27
./configure --prefix=/usr/local/apache --enable-mods-shared=most
make
make install
6.安装mod_mono
cd /usr/local/src
tar -xjvf mod_mono-2.10.tar.bz2
cd mod_mono-2.10
./configure
make
make install
7.安装xsp
xsp就是mod-mono-server。
安装之前,先设置一下环境变量
vi /etc/profile #在最后加上下面这句
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
source /etc/profile 或者注销重新登陆一下
cd /usr/local/src
tar -xjvf xsp-2.10.2.tar.bz2
cd xsp-2.10.2
./configure --prefix=/usr/local
make
make install
8.配置apache
打开/usr/local/apache/conf文件夹中的httpd.conf,这个文件是apache的配置文件,在最后添加
Include /usr/local/apache/conf/mod_mono.conf
将以下#注释去掉
#ServerName www.example.com:80
在/usr/local/apache/htdocs文件夹中任意创建一个index.aspx文件,添加内容如下
<%@ Page Language="C#" %>
<html>
<head>
<title>hello world</title>
</head>
<body>
<%
for (int i=1; i<=7; i++)
{
Response.Write("<font size=" + i.ToString() + ">");
Response.Write("hello world");
Response.Write("</font><br />");
}
%>
</body>
</html>
当然,你也可以网络,去下载一个asp.net探针
重启apache
/usr/local/apache/bin/apachectl restart
通过浏览器访问http://IP/index.aspx,测试asp.net环境搭建是否成功,如果返回“hello world” 说明安装成功

❻ linux 下java读取配置文件

  1. 如果是相对路径无论windows还是linux都是一样的。

  2. 如果是绝对路径,只需要看好配置文件所在linux的目录,其他的操作和windows一样(例如:linux【/usr/local/src/1.config】,windows【c:/1.config】)

  3. 使用File就可以直接读取了。

❼ 如何把linux服务器的文件下到本地windows

既然使用了java,实现这种功能就与OS无关了,否则叫什么跨平台。其实用浏览器下载服务器端文件比较容易:首先,要让用户能找到并选择文件(jsp里实现,部分代码)StringrealPath=request.getSession().getServletContext().getRealPath("")+"/documents";//项目根目录下文件路径FilefileDir=newFile(realPath);String[]fileList=fileDir.list();//返回目录下文件名称数组for(inti=0;ifilelength){//最后一次传送的字节数byte[]leftpart=newbyte[1024-(int)(totalsize-filelength)];//读入字节数组in.readFully(leftpart);//写入输出流servletOut.write(leftpart);}else{//读入1024个字节到字节数组bin.readFully(b);//写和输出流servletOut.write(b);}}servletOut.close();}/***@paramfileName*@paramfileDownloadType*@paramres*@throwsFileNotFoundException*@throwsIOException*/publicstaticvoidDownload(StringfileName,StringfileDownloadType,HttpServletResponseres)throwsFileNotFoundException,IOException{StringfileContentType=null;if(fileName.endsWith(".doc")){fileContentType="application/msword";}elseif(fileName.endsWith(".pdf")){fileContentType="application/pdf";}elseif(fileName.endsWith(".xls")){fileContentType="application/vnd-ms-excel";}elseif(fileName.endsWith(".txt")){fileContentType="text/plain";}else{fileContentType="application/octet-stream";}longtotalsize=0;//取得要传输的文件,实际应用是可以将文件路径以参数的形式传入Filef=newFile(fileName);//取文件长度longfilelength=f.length();byte[]b=newbyte[1024];//设置文件输出流FileInputStreamfin=newFileInputStream(f);DataInputStreamin=newDataInputStream(fin);intpos=fileName.lastIndexOf(java.io.File.separator);Stringfn=newString(fileName.substring(pos+1).getBytes("gb2312"),"ISO8859-1");//设置相应头信息,让下载的文件显示保存信息res.setContentType(fileContentType);res.setHeader("Content-Disposition",fileDownloadType+";filename=\""+fn+"\"");//确定长度Stringfilesize=Long.toString(filelength);//设置输出文件的长度res.setHeader("Content-Length",filesize);//取得输出流ServletOutputStreamservletOut=res.getOutputStream();//发送文件数据,每次1024字节,最后一次单独计算while(totalsizefilelength){//最后一次传送的字节数byte[]leftpart=newbyte[1024-(int)(totalsize-filelength)];//读入字节数组in.readFully(leftpart);//写入输出流servletOut.write(leftpart);}else{//读入1024个字节到字节数组bin.readFully(b);//写和输出流servletOut.write(b);}}servletOut.close();}}

❽ linux和安卓Android中除了某个进程其他后台所有运行的进程杀死命令怎么写

使用ActivityManager的killBackgroundProcesses(packageName)方法可以强制性的关闭packageName关联的执行。这个方法的特点是不可以自杀,只能杀死其他进程。关键代码:
public void onClick(View v) {

String packageName = textPackageName.getText().toString();//获得包名
ActivityManager am = (ActivityManager) getSystemService(ACTIVITY_SERVICE);//获得获得管理器
am.killBackgroundProcesses(packageName);//通过包名杀死关联进程
}

❾ java程序里调用linux命令

1.Java调用shell

Java语言以其跨平台性和简易性而着称,在Java里面的lang包里(java.lang.Runtime)提供了一个允许Java程序与该程序所运
行的环境交互的接口,这就是Runtime类,在Runtime类里提供了获取当前运行环境的接口。
其中的exec函数返回一个执行shell命令的子进程。exec函数的具体实现形式有以下几种:
public Process exec(String command) throws IOException
public Process exec(String command,String[] envp) throws
IOException
public Process exec(String command,String[] envp,File dir) throws
IOException
public Process exec(String[] cmdarray) throws IOException
public Process exec(String[] cmdarray, String[] envp) throws
IOException
public Process exec(String[] cmdarray, String[] envp,File dir)
throws IOException

我们在这里主要用到的是第一个和第四个函数,具体方法很简单,就是在exec函数中传递一个代表命令的字符串。exec函数返回的是一个Process类
型的类的实例。Process类主要用来控制进程,获取进程信息等作用。(具体信息及其用法请参看Java doc)。

1)执行简单的命令的方法:

代码如下:

热点内容
java面试复习 发布:2024-05-07 06:01:15 浏览:657
suftp 发布:2024-05-07 06:00:40 浏览:879
编程的tr 发布:2024-05-07 05:37:25 浏览:422
苹果4s的数据怎么备份到安卓上 发布:2024-05-07 05:37:15 浏览:818
安卓怎么注册电邮 发布:2024-05-07 05:23:49 浏览:714
怎么看清被涂鸦的内容安卓手机 发布:2024-05-07 05:16:52 浏览:702
配置业务分类时主要考虑哪些原因 发布:2024-05-07 05:12:40 浏览:185
外网如何访问内网ip 发布:2024-05-07 05:12:30 浏览:814
网易版有拔刀剑的服务器叫什么 发布:2024-05-07 04:56:35 浏览:752
中国好源码 发布:2024-05-07 04:56:29 浏览:872